Unable to read cookies in FireFox/Chrome via 302 redirect, but works in IE

被刻印的时光 ゝ 提交于 2019-12-05 18:30:22

When saving up a cookie, the domain of the website is also being saved - this is made to avoid cross-domain data exchange - which means: once you save up a cookie from one host - it CANNOT be read from another whatsoever.

but, you can pass the cookie's data via the URL from your original host:

protected void Page_Load(object sender, EventArgs e)
{
    HttpCookie cookie = Request.Cookies["DisCookie"];
    if (cookie != null)
    {
         Response.Redirect("http://www.nkmekal.com/ReadCookie.aspx?data=" + cookie.Value);
    }

    else Response.Redirect("http://www.nkmekal.com/ReadCookie.aspx");
}

And then just usedata in ReadCookie.aspx.

I have finally figured out an alternative and it works just fine! Here is what I've did:

If nkmekal.com creates a DisCookie...I am issueing a 302 redirect to incesscantcoding.com with an encrypted token as a querystring value, then incessentcoding.com will create its own DisCookie based on the querystring value for its domain, so if I want to know if a cookie exists for nkmekal.com I will just look at the Cookies collection for a DisCookie in incessantcoding.com ... I tested this scenario and it seems to be working in both firefox and chrome...

AND later I figured that even google does similar thing when a user logs into one of their service websites...

Hope this helps...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!