$2.84

how to clear cookies from browser c#

Ask a question+
1

how to clear cookies from browser c#

add comment

1 Answer

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);
}

also

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);
}
Gor13666_ 900
add comment

Your Answer