我从进程内成员资格提供程序转换为 sql 成员资格提供程序,以防止人们在网站进程回收时丢失他们的会话,但会话似乎仍然超时。
在使用 sql 成员资格提供程序时,是否有任何其他事情(除了 web.config 中设置的会话超时变量)会导致会话超时。即使用户关闭并打开浏览器,我也希望会话持续存在。我必须做一些特别的事情来做到这一点吗?
我从进程内成员资格提供程序转换为 sql 成员资格提供程序,以防止人们在网站进程回收时丢失他们的会话,但会话似乎仍然超时。
在使用 sql 成员资格提供程序时,是否有任何其他事情(除了 web.config 中设置的会话超时变量)会导致会话超时。即使用户关闭并打开浏览器,我也希望会话持续存在。我必须做一些特别的事情来做到这一点吗?
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.
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.
我认为关闭窗口后不可能保持会话。用户帐户由会话 cookie 编制索引,并在他们关闭窗口时被删除。
您可以做的是存储用户配置文件信息,并在他们登录或以其他方式识别自己(例如普通 cookie)时将其恢复。