javascript - 为 .example.com 设置的 cookie 是否适用于所有子域或仅适用于第三级域?

标签 javascript php cookies

我正在为 .example.com 设置 cookie。我知道 cookie 是随请求发送到 www.example.comsecure.example.com 的,但是它会随请求发送到 server.www .example.comlong.sub.domain.name.for.example.com 怎么样?

最佳答案

我不明白 manual冷得更清楚:

The domain that the cookie is available to. Setting the domain to 'www.example.com' will make the cookie available in the www subdomain and higher subdomains. Cookies available to a lower domain, such as 'example.com' will be available to higher subdomains, such as 'www.example.com'. Older browsers still implementing the deprecated » RFC 2109 may require a leading . to match all subdomains.

如果您不喜欢这个解释,测试它只需不到 5 分钟

one.two. Three.example.com 高于 third.example.com 两者都是 example.com

的子域

关于javascript - 为 .example.com 设置的 cookie 是否适用于所有子域或仅适用于第三级域?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21687381/

相关文章:

java - 无法将 cookie 从 Selenium webdriver 传递到 clojure 中的 httpclient cookie 存储

javascript - 子文件夹中未设置 cookie

javascript - 移动 Web 应用程序 - 多页面还是 AJAX?

javascript - 如何增加 Mailchimp JavaScript 弹出窗口的上边距

php - 使用 gmail(windows) 从本地主机发送电子邮件

php - 检查数组中有多少值大于 x

javascript - phonegap 中的“This”

javascript - Phonegap 从白名单 URL 打开应用程序外部的外部链接

php - 用户点击链接后如何显示引用名称?

javascript - HTML5 - 本地存储、Cookie 和 SQL