0

我有个问题。我已经使用 cookie 完成了自定义的“记住我”功能。

 HttpCookie rememberMeCookie = FormsAuthentication.GetAuthCookie(userName, rememberMe);
 if (rememberMe)
 {
     rememberMeCookie.Expires = Controller.LocalizationProvider.GetAdjustedServerTime().AddMonths(6);
 }

 HttpContext.Current.Response.Cookies.Add(rememberMeCookie);

我在 Firefox 的 firecookies 工具中看到了 cookie。它存在并具有正确的到期日期。但是当我改变时间 - 移动到下个月。之后,我进入该站点并取消了用户登录。如果我回到现在 - 我成为了认证用户。

4

1 回答 1

1

可能是您的 web.config 中的表单身份验证超时造成干扰。这是 MSDN 不得不说的:

在 ASP.NET V1.1 下,持久 cookie 不会超时,无论 timeout 属性的设置如何。但是,从 ASP.NET V2.0 开始,持久性 cookie 会根据 timeout 属性超时。

于 2011-03-25T01:44:58.397 回答