Tag: 记住我

记住我在ASP.NET表单身份validation中的function不起作用

我正在使用ASP.NET表单身份validation将用户登录到我们正在开发的网站中。 部分function是“记住我”复选框,如果用户检查,则会记住用户一个月。 用户登录的代码如下: public static void Login(HttpResponse response, string username, bool rememberMeChecked) { FormsAuthentication.Initialize(); FormsAuthenticationTicket tkt = new FormsAuthenticationTicket(1, username, DateTime.Now, DateTime.Now.AddMinutes(30), rememberMeChecked, FormsAuthentication.FormsCookiePath); HttpCookie ck = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(tkt)); ck.Path = FormsAuthentication.FormsCookiePath; if (rememberMe) ck.Expires = DateTime.Now.AddMonths(1); response.Cookies.Add(ck); } web.config中的相关部分是这样的: 这会记录用户正常但如果他们不使用该站点,则在半小时后将其记录下来,尽管其持久性属性(rememberMeChecked)设置为true,如果为true,则cookie设置为在一个月后过期。 这里有什么我想念的吗? 在此先感谢,F