Wednesday, April 20, 2016

Deleting or expiring cookies

If you ever have a need to delete or expire a Cookie that you create through ASP.NET or ASP.NET MVC, fortunately, MSDN has just an article on how to accomplish that!

if (Request.Cookies["UserSettings"] != null)
    HttpCookie myCookie = new HttpCookie("UserSettings");
    myCookie.Expires = DateTime.Now.AddDays(-1d);

Pretty simple, right??

No comments:

Post a Comment