当用户关闭浏览器时,如何清除通过我的 ASP.NET MVC(C#) 应用程序存储的 Cookie?
是否有任何选项可以创建 cookie,使其在浏览器关闭后过期?
我需要使用cookie,因为我将存储一些要维护的值,直到浏览器关闭。
例如,在登录期间,我可以将用户 ID 存储在 cookie 中,我可以将其用于我的应用程序进程,直到 bwoser 关闭。
session 将在某个特定时间后过期,我需要使用 cookie 来克服这个问题
最佳答案
session 通常用于此目的。根据Wikipedia ,如果未设置过期日期,则当用户关闭浏览器时将清除 cookie。
The cookie setter can specify a deletion date, in which case the cookie will be removed on that date. If the cookie setter does not specify a date, the cookie is removed once the user quits his or her browser.
关于cookies - 关闭浏览器时清除 cookie,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1783302/