Monday, January 28, 2013

How to delete cookies in ASP.NET?

In fact, delete mean "expire"

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

No comments:

Post a Comment