【发布时间】:2011-08-06 07:03:11
【问题描述】:
我们有 2 个测试环境,分别是:
- http://test.example.com/(这是我们的 前端 CMS 测试站点)
- http://test-example/(这是我们的 形成的内部开发网站 收集数据等)
以下是写入“test.example.com”域的 cookie。用户将到达将 cookie 写入其计算机的页面,然后他们将单击一个链接将他们带到“test-example”,这是我们的内部测试域。我观察到,当他们离开“test.example.com”并被带到我们的内部测试域“test-example”时,cookie 没有跟随,因此我无法读取 cookie。
是否有人可以帮助我编写代码以允许跨我们的内部测试域读取 cookie?
<script type="text/javascript">
var cookieName = 'HelloWorld';
var cookieValue = 'HelloWorld';
var myDate = new Date();
myDate.setMonth(myDate.getMonth() + 12);
document.cookie = cookieName +"=" + cookieValue + ";expires=" + myDate
+ ";domain=.example.com;path=/";
</script>
【问题讨论】:
标签: javascript cookies dns