设置多个子域的Cookie [英] Setting cookies for multiple sub-domains

查看:130
本文介绍了设置多个子域的Cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以为 http://www.example.com 设置Cookie ,位于 https://secure.example.com >?我有一些代码给我,似乎试图和失败在这。

Is it possible to set a cookie for http://www.example.com from a PHP file located at https://secure.example.com? I have some code that was given to me, that appears to try and fails at this. I was wondering if this is possible at all.

推荐答案

网页只能为第二(或更高级)级域设置Cookie

Webpages can only set cookies for the second (or higher) level domain that they belong to.

这意味着 secure.example.com 可以读取和设置 secure.example.com .example.com ,后者也可以通过 www.example.com

This means that secure.example.com can read and set cookies for secure.example.com or .example.com, the latter of which can also be read and set by www.example.com

最后一个注意事项:如果安全标记设置在Cookie上,则只能通过https连接。

One last note: If the secure flag is set on a cookie, it can only be read and set over an https connection.

这篇关于设置多个子域的Cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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