how to clear cookies from browser c#

Ask a question
1

how to clear cookies from browser c#

Coin iconoffer bounty
add comment

2 Answers

1

public static void DeleteCookie(
HttpRequest request, HttpResponse response, string name)
{
if (request.Cookies[name] == null) return;
var cookie = new HttpCookie(name) {Expires = DateTime.Now.AddDays(-1d)};
response.Cookies.Add(cookie);
}

add comment
1

HttpCookie aCookie;
string cookieName;
int limit = Request.Cookies.Count;
for (int i=0; i<limit; i++)
{
cookieName = Request.Cookies[i].Name;
aCookie = new HttpCookie(cookieName);
aCookie.Expires = DateTime.Now.AddDays(-1);
Response.Cookies.Add(aCookie);
}

add comment

Your Answer