[英]When is a cookie available?
Hi i have a web application where i plant a cookie on my page. 嗨,我有一个Web应用程序,我在页面上植入了cookie。 Then the user goes to another page, and from that page calls my page from a script, like this:
然后用户转到另一个页面,并从该页面通过脚本调用我的页面,如下所示:
<script type="text/javascript" src="http://domain.com/page.aspx?id=6" ></script>
But i cant access the cookie when it calls my page, why not? 但是当它调用我的页面时,我无法访问Cookie,为什么不呢? and how to work around it?
以及如何解决?
Please note that this question is in relation to: Javascript and webshop tracking/affiliate across websites, how to do? 请注意,该问题与以下内容有关: Javascript和Webshop跨网站跟踪/关联,该怎么办?
Edit The "other" page is on a entirely different domain. 编辑 “其他”页面位于完全不同的域中。 My code is in ASP.NET, but as far as i know its the same for all languages:
我的代码在ASP.NET中,但是据我所知,所有语言都相同:
Planting the cookie (Default.aspx): 植入cookie(Default.aspx):
protected void Page_Load(object sender, EventArgs e)
{
Response.Cookies["affiliate"].Value = "InnovationPartner";
Response.Cookies["affiliate"].Expires = DateTime.Now.AddDays(7);
...
}
Retrieving the cookie (after round-trip) (Collect.aspx): 检索cookie(往返后)(Collect.aspx):
protected void Page_Load(object sender, EventArgs e)
{
bool affiliate = Request.Cookies["affiliate"] != null ? true : false;
...
}
Many browsers have options to place limitations on 'third party cookies', which is what your cookies are for a request caused by a <script>
tag on another site. 许多浏览器都可以选择对“第三方Cookie”进行限制,这就是您的Cookie是针对另一个网站上的
<script>
标记引起的请求的。
In particular for IE's default settings, you will need to provide a P3P policy. 特别是对于IE的默认设置,您将需要提供P3P策略。 See eg.
参见例如。 this question .
这个问题 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.