PHP中的跨HTTP和HTTPS的Cookie [英] Cookie across HTTP and HTTPS in PHP

查看:347
本文介绍了PHP中的跨HTTP和HTTPS的Cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在PHP中设置一个在HTTP和HTTPS中都可读的cookie?

How can I set a cookie in PHP that is readable both in HTTP and HTTPS?

如果这是不可能的,可以做什么?设置两个cookie?

If this isn't possible, what can be done? Set two cookies?

推荐答案

假设您的域名保持不变,除了资源类型,PHP(或任何语言)可以从HTTP和HTTPS读取。

Assuming your domain name remains the same except for the resource type, cookies in PHP (or any language) can be read from both HTTP and HTTPS.

例如:

http://www.example.com
https://www.example.com

在此示例中,Cookie将可以相互读取。

In this example, the cookies will be readable from each other.

这篇关于PHP中的跨HTTP和HTTPS的Cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆