locked
Cookie not saved on .local URL RRS feed

  • Question

  • User923737044 posted

    I have a website which is available at both the machine name-URL (something.something.local) and on a more readable URL in the dk-domain (somethingelse.dk). I have implemented a cookie with the code below. When I visit the site on the .dk URL, the cookie is stored as expected. If I visit the site on the .local URL, the cookie is not stored. Is there some kind of limitation or what can I do to make it work on both URLs?

    var cookie = new HttpCookie(CookieName)
    {
      Expires = DateTime.Now.AddMonths(1)
    };
    cookie.Values["myKey1"] = "somevalue1";
    cookie.Values["myKey2"] = "somevalue2";
    Response.Cookies.Add(cookie);



    Friday, February 8, 2013 7:11 AM

All replies

  • User-760709272 posted

    Cookies are only available to code running on the domain (or sub-domain if configured) that created them.  One site can't read another site's cookies and this is by design.

    Friday, February 8, 2013 7:33 AM
  • User923737044 posted

    Alright, I think I was a bit unclear before - sorry about that. This is what I experience on the two sites:

    .dk URL: Cookie is stored and read as expected. If I view cookie information on this site in IE (F12 --> Cache --> Cookie information), I can see the cookie related to the .dk site.

    .local URL: Cookie is not stored or updated but it seems to read the cookie of the .dk site. If I view cookie information on this site, there is no cookie to see (I cannot see the .dk cookie either).

    I'm not sure that the information provided by AidyF explains this behavior. Or does it?

    Friday, February 8, 2013 7:53 AM
  • User923737044 posted

    Any ideas on this?

    Tuesday, February 12, 2013 3:59 AM
  • User1519735232 posted

    http://www.velocityreviews.com/forums/t75390-cookies-not-saving.html

    Thursday, March 7, 2013 10:18 PM