cookies - 关闭浏览器时清除 cookie

标签 cookies browser

当用户关闭浏览器时,如何清除通过我的 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/

相关文章:

servlets - session cookie Websphere 7 的安全和 HttpOnly 标志

html - 浏览器密码管理器只能记住用户名吗?

javascript - 浏览器重启后sessionStorage不清除

security - 为什么 FormsAuthentication 的 requireSSL 属性默认为 false!

php - $_COOKIE 仅存储最后插入的值

reactjs - React App + Spring Boot - Chrome 中未设置 cookie 内的 JWT 身份验证 token

forms - jQuery UI 选项卡和 Cookie 选项出现问题

浏览器不接受 XML 1.1 版?

python - 调用 python webbrowser 时抑制/重定向 stderr

html - 字体渲染在 Internet Explorer 上太难看