【发布时间】:2010-08-25 14:22:50
【问题描述】:
有两个域: a.example.com example.com
example.com 是 a.example.com 的父域。现在 a.example.com 和 example.com 都可以写入一个名为 test_cookie 的 cookie。现在我们有一个 a.example.com 页面,它将使用 javascript 读取 cookie test_cookie 的值。有没有办法只读取a.example.com的域中设置的cookie而不是example.com?
也许我的问题有点不清楚,
我想要达到的目标是: 1. 我想编写一个名为 readCookie 的函数来读取名为 test_cookie 的 cookie,其中: 一个。当有 cookie 时:example.com 域下的 test_cookie 和 a.example.com 域下的无 cookie test_cookie >, readCookie 返回 null 湾。当有 cookie 时:域 example.com 下的 test_cookie 和域 a.example.com 下的 cookie test_cookie strong>,readCookie 返回域 a.example.com 下的 cookie 值 C。当没有cookie时:exampler.com下的test_cookie,但域a.example.com下有一个cookietest_cookie strong>,readCookie返回域a.example.com下的cookie值。
【问题讨论】:
标签: javascript cookies