Sharepoint 2010 setting a cookie expiration date seemsto work when viewed from browser but server code sees 01/01/0001 expiration

StackOverflow https://stackoverflow.com/questions/13261316

Question

here is the to add the cookie to the request

    HttpCookie cookie = new HttpCookie(myCookie);
    cookie.Expires = DateTime.Now.AddDays(30);
    cookie.Value = myValue;
    cookie.Domain = myDomain;
    cookie.HttpOnly = true;
    response.Cookies.Add(cookie);

Seems fine, until during a Sharepoint 2010 context.PostAuthenticateRequest event when i try to read the cookie

    HttpCookieCollection cookies = request.Cookies;
        HttpCookie tosCookie = cookies.Get(TOS_COOKIE_KEY_ACKNOWLEDGEMENT);
        tosCookie.Expires

i get the date 01/01/0001 when in the browser i see the cookie expiration date as 12/6/2012

Was it helpful?

Solution

Yes, server does not know expiration time on incoming cookies.

Browser does not send expired cookies to server and does not in any way let server know what cookie expiration is.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top