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

質問

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

役に立ちましたか?

解決

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top