持久身份验证令牌过期

发布于 2024-12-21 14:32:40 字数 765 浏览 3 评论 0原文

我有一个使用表单身份验证的 ASP.NET MVC 应用程序。下面是我创建身份验证令牌的代码行:

FormsAuthentication.SetAuthCookie(username, true);

我的 web.config 包含:

<system.web>
  <machineKey validationKey="{unique key}" decryptionKey="{unique key}" validation="SHA1" decryption="AES" />
  <authentication mode="Forms">
    <forms loginUrl="~/account/" timeout="2880" />
  </authentication>
  ...
</system.web>
<location path="my">
  <system.web>
    <authorization>
      <deny users="?" />
    </authorization>
  </system.web>
</location>

尽管持久 cookie 的参数设置为 true,但我的用户在几天不活动后就会注销。

该应用程序部署到 AppHarbor,但当它托管在专用服务器上时,我遇到了相同的行为。

我错过了什么会导致用户偶尔注销?

I have an ASP.NET MVC application using forms authentication. Here's the line of code where I create the auth token:

FormsAuthentication.SetAuthCookie(username, true);

My web.config contains:

<system.web>
  <machineKey validationKey="{unique key}" decryptionKey="{unique key}" validation="SHA1" decryption="AES" />
  <authentication mode="Forms">
    <forms loginUrl="~/account/" timeout="2880" />
  </authentication>
  ...
</system.web>
<location path="my">
  <system.web>
    <authorization>
      <deny users="?" />
    </authorization>
  </system.web>
</location>

Despite the parameter for the persistent cookie being set to true, my users get logged out after a few days of inactivity.

The app is deployed to AppHarbor, but I experienced the same behavior when it was hosted on a dedicated server.

What am I missing that would cause users to get logged out sporadically?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

素衣风尘叹 2024-12-28 14:32:40

你的超时设置为2880分钟,也就是48小时?

超时用于指定表单身份验证会话的有限生命周期。默认值为 30 分钟。如果发出持久表单身份验证 cookie,则超时属性还用于设置持久 cookie 的生命周期。

http://msdn.microsoft.com/en-us/library/ ff647070.aspx

Your timeout is set to 2880 minutes, which is 48 hours?

timeout is used to specify a limited lifetime for the forms authentication session. The default value is 30 minutes. If a persistent forms authentication cookie is issued, the timeout attribute is also used to set the lifetime of the persistent cookie.

http://msdn.microsoft.com/en-us/library/ff647070.aspx

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