点击注销登陆按钮没法清除cookie,但退出浏览器就可以,求解决方法?
//登陆
string cm = System.Configuration.ConfigurationManager.AppSettings["kell"];
Response.Cookies["a"].Value = qq.Value.Trim();
Response.Cookies["b"].Value = ww.Value.Trim();
Response.Cookies["c"].Value = wwqq.value.Trim();
Response.Cookies["a"].Domain = cm;
Response.Cookies["b"].Domain = cm;
Response.Cookies["c"].Domain = cm;
//注销登陆
string cookiedomain = System.Configuration.ConfigurationManager.AppSettings["kell"];
context.Response.Cookies["a"].Domain = cookiedomain;
context.Response.Cookies["b"].Domain = cookiedomain;
context.Response.Cookies["c"].Domain = cookiedomain;
context.Response.Cookies["a"].Value = null;
context.Response.Cookies["a"].Expires = DateTime.Now.AddDays(-1);
context.Response.Cookies["b"].Value = null;
context.Response.Cookies["b"].Expires = DateTime.Now.AddDays(-1);
context.Response.Cookies["c"].Value = null;
context.Response.Cookies["c"].Expires = DateTime.Now.AddDays(-1);
点击注销登陆按钮没法清除cookie,但退出浏览器就可以,求解决方法?
------解决方案--------------------MyCo = HttpContext.Current.Request.Cookies["UserID"];
if (MyCo != null)
{
MyCo.Expires = DateTime.Now.AddHours(-48);
HttpContext.Current.Response.Cookies.Add(MyCo);
}
------解决方案--------------------Response.Cookies.Clear();
------解决方案--------------------1 2楼把 时间过期, 和 清除cookies都写了。. 没我什么事情了
------解决方案--------------------
设置Cookie的方法是
HttpCookie x = new HttpCookie()
context.Response.Cookies.Add(x)
不是设置context.Response.Cookies
------解决方案--------------------把cookie移除就行了·
------解决方案--------------------
设置过期时间为-1在保存就可以了。不能直接删除。只能设置过期时间