使通过 FormAuthentication 设置的 cookie 过期
我在登录时使用了 MemberShipUser API,
FormAuthentication.SetAuth(username, false);
如果用户不注销并直接关闭浏览器,我们正在验证用户并创建 FormAuthentication,则不会调用 FormAuthentication.SignOut 方法。
因此,当我们重新打开网站时,用户已经登录。
I have used MemberShipUser API on Login we are validating user and creating FormAuthentication
FormAuthentication.SetAuth(username, false);
now if user doesnot logout and close the browser directly FormAuthentication.SignOut method is not called.
due to which when we reopen the website the user is already logged in.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将超时值配置为适当的数字或使用 cookie less 表单身份验证。
http://msdn.microsoft.com/en-us/library/ff647070.aspx #pageexplained0002_cookielessforms
Either configure the timeout value to an appropriate number or use cookie less forms authentication.
http://msdn.microsoft.com/en-us/library/ff647070.aspx#pagexplained0002_cookielessforms
身份验证 cookie 仍然有效。当用户再次打开网站时,cookie 会显示用户仍处于登录状态。
您可以使 cookie 的生命周期较短,这样它更有可能过期:
但是据我所知,如果用户不注销,他们不会立即注销退出。
^^除非你不像hasan-khan所说的那样使用cookie(它在查询字符串中传递一个id,这看起来不太好。)
The authentication cookie will still be valid. When the user opens the site again, the cookie says the user is still logged in.
You can make the cookie short lived so it's more likely to have expired:
but afaik, if the user doesn't log out they won't be immediately logged out.
^^Unless you don't use cookies as hasan-khan says (it passes an id in the querystring which doesn't really look very nice.)