首页 > 代码库 > 清除cookie
清除cookie
private static void DetelteAllCookies(string domain)
{
if (HttpContext.Current.Request.Cookies["userToken"] == null)
{
string cookieName;
int limit = HttpContext.Current.Request.Cookies.Count;
for (int i = 0; i < limit; i++)
{
cookieName = HttpContext.Current.Request.Cookies[i].Name;
HttpContext.Current.Response.Cookies.Remove(cookieName);
HttpContext.Current.Response.Cookies[cookieName].Domain = domain;
HttpContext.Current.Response.Cookies[cookieName].Expires = DateTime.Now.AddDays(-1);
HttpContext.Current.Response.Cookies[cookieName].Value = http://www.mamicode.com/null;
}
}
}
清除cookie