使用 SQL 成员资格提供程序的 ASP.NET 会话超时

发布于 2024-07-11 17:51:22 字数 200 浏览 8 评论 0原文

我从 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

霊感 2024-07-18 17:51:22

使用持久性 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.

心的憧憬 2024-07-18 17:51:22

我认为关闭窗口后不可能保留会话。 用户帐户由会话 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).

枯寂 2024-07-18 17:51:22

您混淆了会话(其本质上会过期,并且应该仅适用于单个会话的瞬态数据)和配置文件。 您可以使用 ASP.NET 的成员数据库功能来设置持久性设置,但它们只有在用户保持登录状态时才会重新出现。

但是...还有匿名标识。 您可以在 web.config 中启用此功能

<anonymousIdentification enabled="true"/>   

,然后将您的个人资料设置标记为可供匿名用户使用;

<profile>
  <properties>
    <add name="Name" allowAnonymous="true" />
  </properties>
</profile>

匿名 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

<anonymousIdentification enabled="true"/>   

And then mark your profile settings as available to an anonymous user;

<profile>
  <properties>
    <add name="Name" allowAnonymous="true" />
  </properties>
</profile>

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文