Skip to content

Instantly share code, notes, and snippets.

@MajidSafari
Created November 24, 2014 21:07
Show Gist options
  • Save MajidSafari/f9b1be52132111cb0a69 to your computer and use it in GitHub Desktop.
Save MajidSafari/f9b1be52132111cb0a69 to your computer and use it in GitHub Desktop.
Clear All Cookie C# Asp.net
string[] myCookies = Request.Cookies.AllKeys;
foreach (string cookie in myCookies)
{
var httpCookie = Response.Cookies[cookie];
if (httpCookie != null)
{
httpCookie.Expires = DateTime.Now.AddYears(-10);
Response.Cookies.Add(httpCookie);
}
var httpCookie1 = Response.Cookies[cookie];
if (httpCookie1 != null)
{
httpCookie1.Expires = DateTime.Now.AddYears(-10);
httpCookie1.Domain = ".kanoon.ir";
Response.Cookies.Add(httpCookie1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment