this.Response.Cookies["adminusers"].Expires = DateTime.Now.AddDays(-1);
Response.Cookies.Add(Request.Cookies["adminusers"]);
Response.Redirect("/login.aspx");
为什么不能设置过期呢是因为你没写入客户端把cookie
Response.Cookies.Add(Request.Cookies["adminusers"]);
这就话就是把cookie写回客户端
只有加这句才好用
不行的用以下的代码清楚全部的cookie
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);
}
posted on 2009-02-26 19:23
sanmao 阅读(768)
评论(0) 编辑 收藏