【问题标题】:expiration date in newly created authentication ticket (asp.net forms auth)新创建的身份验证票证中的到期日期(asp.net forms auth)
【发布时间】:2009-02-19 17:24:02
【问题描述】:

我正在使用 asp.net 表单身份验证和 asp.net 登录控件。登录控件有一个“RememberMe”复选框。

用户通过身份验证后,它会引发 LoggedIn(object sender, EventArgs e) 方法,在此方法中,我正在查看使用此方法创建的身份验证 cookie

HttpCookie authCookie = FormsAuthentication.GetAuthCookie(userName, true);

当我检查 authCookie.Expires 值时,我希望它是 30 分钟(不检查 RememberMe)和 50 年(根据 MS 文档,这些是默认值)

但无论我是否检查RememberMe,它总是30 分钟。我检查了我的 web.config 并且我没有为“超时”字段设置任何内容,所以我不确定为什么会发生这种情况。有什么想法吗?

【问题讨论】:

    标签: asp.net cookies forms-authentication


    【解决方案1】:

    这很令人困惑,但看起来我必须在我的 web.config 中的 authentication/forms 部分下设置“超时”和“slidingExpiration”,才能让 RememberMe 部分正常工作

    我已经设置好了,一切都按预期工作

    slidingExpiration="true" timeout="5120" 
    

    rick strahl 的博客帮我找到了答案 http://www.west-wind.com/WebLog/posts/157861.aspx

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-12
      • 1970-01-01
      • 1970-01-01
      • 2019-11-27
      • 1970-01-01
      相关资源
      最近更新 更多