Skip to main content David Edelstein's Blog

C# - How to delete cookie from .Net - Stack Overflow

Published: 2015-04-23
David Edelstein

To remove a cookie, remove it from the response, then add a new cookie with a blank value that has already expired. I’m not sure why Response.Cookies.Remove doesn’t get this to work. But the following does:

HttpCookie currentUserCookie = HttpContext.Current.Request.Cookies["currentUser"];
currentUserCookie.Expires = DateTime.Now.AddDays(-10);
currentUserCookie.Value = null;

(via c# - How to delete cookie from .Net - Stack Overflow)