How do you remove HttpOnly cookies?

Chris Marisic picture Chris Marisic · Oct 8, 2010 · Viewed 8.4k times · Source

If my application places HttpOnly cookies on a client and then needs to remove them how can you remove them completely?

Answer

Waleed Eissa picture Waleed Eissa · Oct 8, 2010

You can cause the cookie to expire when the user visits your website, for example:

HttpCookie expiredCookie = new HttpCookie(cookieName);
expiredCookie.Expires = DateTime.UtcNow.AddDays(-1);
Response.Cookies.Add(expiredCookie);

You'll have to do this for every cookie you want to be removed.