使用 SQL 成员资格提供程序的 ASP.NET 会话超时
我从 in-process 成员资格提供程序更改为 sql 成员资格提供程序,以防止人们在网站进程回收时丢失会话,但会话似乎仍然超时。
使用 sql 成员身份提供程序时,是否有任何其他因素(除了 web.config 中设置的会话超时变量之外)会导致会话超时。 我希望即使用户关闭并打开浏览器,会话也能持续存在。 我必须做一些特别的事情才能做到这一点吗?
I changed over from the in process membership provider to the sql membership provider to stop people losing their sessions when the website process recycled, but sessions still seem to time out.
Are there any other things (apart from the session timeout variable set in the web.config) that would cause a session to timeout when using sql membership provider.
I want the session to persist even when the user closes and opens the browser. Must I do anything special to do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用持久性 cookie(“记住我复选框”),用户可以在 3 天后登录。 如果你想让这个窗口更大,你需要自己建造它。
With persistent cookies ('the remember me checkbox'), the user is logged in by 3 days. If you want to make this window bigger, you'll need to build it yourself.
我认为关闭窗口后不可能保留会话。 用户帐户由会话 cookie 索引,当用户关闭窗口时,该 cookie 将被删除。
您可以做的是存储用户个人资料信息并在他们登录或以其他方式识别自己时恢复它(例如普通cookie)。
I don't think it is possible to persist a session after closing a Window. The user account is indexed by a session cookie and this is deleted when they close the window.
What you could do is to store user profile information and restore it when they log in or otherwise identify themselves (e.g. normal cookies).
您混淆了会话(其本质上会过期,并且应该仅适用于单个会话的瞬态数据)和配置文件。 您可以使用 ASP.NET 的成员数据库功能来设置持久性设置,但它们只有在用户保持登录状态时才会重新出现。
但是...还有匿名标识。 您可以在 web.config 中启用此功能
,然后将您的个人资料设置标记为可供匿名用户使用;
匿名 cookie 的有效期约为 70 天。 如果您决定支持注册和正式会员资格,则需要在注册时将匿名设置移至用户的设置。
You're confusing session (which by its nature expires and should be for transient data only applicable to a single session) and profiles. You can use the membership database features of ASP.NET to set persistent settings, but they will only reappear if a user remains logged in.
However ... there is also anonymous identification. You can enable this in web.config
And then mark your profile settings as available to an anonymous user;
The anonymous cookie lasts for about 70 days. If you decide to support registration and full blown membership you'd need to move the anonymous settings to a user's settings when they register.