如何在ASP.NET网站上删除Cookie [英] How to delete cookies on an ASP.NET website
本文介绍了如何在ASP.NET网站上删除Cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的网站上,当用户单击注销"按钮时,Logout.aspx页面将加载代码为Session.Clear()
.
In my website when the user clicks on the "Logout" button, the Logout.aspx page loads with code Session.Clear()
.
在ASP.NET/C#中,这会清除所有cookie吗?还是需要添加任何其他代码来删除我网站的所有cookie?
In ASP.NET/C#, does this clear all cookies? Or is there any other code that needs to be added to remove all of the cookies of my website?
推荐答案
尝试类似的方法:
if (Request.Cookies["userId"] != null)
{
Response.Cookies["userId"].Expires = DateTime.Now.AddDays(-1);
}
但是使用
Session.Abandon();
在许多情况下都是这样.
besides in many scenarios.
这篇关于如何在ASP.NET网站上删除Cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文