0

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

Anthony
  • 527
  • 1
  • 8
  • 26

1 Answers1

1

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.

Alexei Levenkov
  • 94,391
  • 12
  • 114
  • 159
  • ok. I needed to know if the cookie was still valid and figured I could use the expiration date of the cookie. If i got a date back then i knew it was valid and if NOT it is expired. I never get the date back regardless. – Anthony Nov 13 '12 at 19:07