I have a problem with cross-domain cookies. I read a lot of documentation on sharing cookies between subdomains. The main idea of ββall articles is to set the Domain property to something like ".mydomain.com". I created two domains on the local IIS server - test1.local.boo and test2.local.boo. They work great and are visible in the browser. I have the following code:
Site test1 - Records a cookie:
HttpCookie myCookie = new HttpCookie("TestCookie"); myCookie.Domain = ".local.boo"; myCookie["msg"] = "Welcome from Cookie"; Response.Cookies.Add(myCookie);
Site test2 - Read cookie:
HttpCookie cookie = Request.Cookies["TestCookie"]; if (cookie != null) { Response.Write(cookie["msg"]); } else { Response.Write("FAILED"); }
This code always shows a FAILED message. Thus, this means that the second site cannot read cookies from the same subdomain. Where is my mistake?
source share