为什么我清空了cookies,再其它页面还能读出来(C#)
清空页面logout.aspx
方法:Request.Cookies.Clear();
Response.Cookies.Clear();
HttpContext.Current.Request.Cookies.Clear();
在首页上还能读书出来
读的方法Request.Cookies["UserName"].Value
我试了在logout.aspx页面上读,
Request.Cookies["UserName"].Value已经清空的,cookeis都没注册,还会报错,
怎么会事????
------解决方案--------------------再新建一个同名过期的cookie
HttpCookie cookie=Request.Cookies["UserName"];
cookie.Expires=DateTime.Now.AddDays(-10);
Response.Cookies.Add(cookie);