本文介绍了如何在Button Click事件中删除Cookies的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在登录时不明白这样的Cookie。
HttpCookie upsceducook = new HttpCookie(userinfo);
upsceducook.Values [username] = uname;
upsceducook.Values [userid] = check.Single()。Id.ToString();
upsceducook.Expires = DateTime.Now.AddYears(1);
Response.Cookies.Add(upsceducook);
然后当退出
Response.Cookies [upsceducook]。Expires = DateTime.Now.AddYears( -1);
Response.Redirect(Home.aspx);
但它不起作用且饼干还活着..给我一个合适的解决方案.Plzzzz
推荐答案
if (Request.Cookies["upsceducook"] != null)
{
HttpCookie myCookie = new HttpCookie("upsceducook");
myCookie.Expires = DateTime.Now.AddDays(-1d);
Response.Cookies.Add(myCookie);
}
Response.Redirect("Home.aspx");
这篇关于如何在Button Click事件中删除Cookies的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!