加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net – 使用FormsAuthentication持久的cookie超时

发布时间:2020-12-15 20:26:29 所属栏目:asp.Net 来源:网络整理
导读:我正在创建一些“记住我”功能作为登录的一部分. 当我在登录过程中创建一个持久性的cookie,具体如下: FormsAuthentication.SetAuthCookie("someusername",true); 而我的Web.Config如下所示: authentication mode="Forms" forms loginUrl="~/sign-in" timeo
我正在创建一些“记住我”功能作为登录的一部分.

当我在登录过程中创建一个持久性的cookie,具体如下:

FormsAuthentication.SetAuthCookie("someusername",true);

而我的Web.Config如下所示:

<authentication mode="Forms">
  <forms loginUrl="~/sign-in" timeout="2880" />
</authentication>

Cookie会在多长时间内被有效提供,才能再次要求用户提供登录信息?
另外还有/设置持久性cookie时使用的默认时间是多少?

解决方法

我找到了我正在寻找的答案感谢这篇文章:

Dan Sellers’s WebLog

他说:

in ASP.NET 2.0 the timeout value of both persistent and session based
cookies are controlled by the timeout attribute on the<forms/>element

所以在我的例子中,持久性cookie将在48小时内到期.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读