Tuesday, February 18, 2014

a better way to destroy a cookie

HttpCookie cookie = Request.Cookies[MagicStrings.IdentityName];
if (cookie != null)
{
   cookie.Value = "";
   cookie.Expires = clock.GiveTime().AddDays(-1);
   Response.Cookies.Add(cookie);
}

 
 

What is above should really replace what is below in this. What is below isn't so wonderful.

HttpCookie cookie = new HttpCookie(MagicStrings.IdentityName, "");
cookie.Expires = clock.GiveTime();
Response.Cookies.Add(cookie);

No comments:

Post a Comment