开发者

When is a cookie available?

Hi i have a web application where i plant a cookie on my page. 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? 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?

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:

Planting the cookie (Default.aspx):

protected void Page_Load(object se开发者_如何学Gonder, EventArgs e)
    {
        Response.Cookies["affiliate"].Value = "InnovationPartner";
        Response.Cookies["affiliate"].Expires = DateTime.Now.AddDays(7);
        ...
    }

Retrieving the cookie (after round-trip) (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.

In particular for IE's default settings, you will need to provide a P3P policy. See eg. this question.


when called from the different domain, a P3P signature must be implemented.
Anyway, you must always watch an HTTP log to track the cookies flow

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜