in .NET Framework

Back to Basics – Deleting Cookies using ASP.NET

You cannot instruct ASP.NET to physically remove cookies from the user’s computer so you have to tell the user’s browser to modify the cookie in order to trigger the browser to remove the cookie.

See code example:

1
2
3
4
5
6
7
8
9
HttpCookie aCookie;
string cookieName;
int limit = Request.Cookies.Count;
for (int i=0; i {
cookieName = Request.Cookies[i].Name;
aCookie = new HttpCookie(cookieName);
aCookie.Expires = DateTime.Now.AddDays(-1);
Response.Cookies.Add(aCookie);
}

 

References:

http://msdn.microsoft.com/en-us/library/ms178194.aspx#Y5776