关于Form验证方式的cookie持久性问题
2010-01-08 15:35
573 查看
找到解决的方法是:authCookie.Expires = authTkt.Expiration;
http://dotnet.org.za/thea/archive/2004/07/27/3010.aspx I'm using Forms Authentication and Role based security for an app I'm working on. Ran into a problem that even though I set the IsPersistent parameter of the FormsAuthenticationTicket to true, next time I open the app I have to log in again...
authTkt =
new FormsAuthenticationTicket(1, userId, DateTime.Now, DateTime.Now.AddYears(1), true
, userRoles);
Well, doh, the plain and simple answer is that you need to set the expiry date of the cookie, otherwise it expires when the user closes the browser. Problem solved :-)
authCookie.Expires = authTkt.Expiration;
More info on ASP.Net cookies on CodeProject.
http://dotnet.org.za/thea/archive/2004/07/27/3010.aspx I'm using Forms Authentication and Role based security for an app I'm working on. Ran into a problem that even though I set the IsPersistent parameter of the FormsAuthenticationTicket to true, next time I open the app I have to log in again...
authTkt =
new FormsAuthenticationTicket(1, userId, DateTime.Now, DateTime.Now.AddYears(1), true
, userRoles);
Well, doh, the plain and simple answer is that you need to set the expiry date of the cookie, otherwise it expires when the user closes the browser. Problem solved :-)
authCookie.Expires = authTkt.Expiration;
More info on ASP.Net cookies on CodeProject.
相关文章推荐
- 关于Form验证方式的cookie持久性问题
- 关于请求方式为GET的form表单,action属性后不能带参数的问题
- 关于form表单以get方式传参的问题
- 关于在非安全信道中的用户名-密码方式的验证安全问题
- 关于cookie储存用serialize方式或json_encode方式转化的数组问题
- asp.net 登陆验证 Form表单验证的3种方式 FormsAuthentication.SetAuthCookie;FormsAuthentication.RedirectFromLoginPage;FormsAuthenticationTicket
- asp.net 登陆验证 Form表单验证的3种方式 FormsAuthentication.SetAuthCookie;FormsAuthentication.RedirectFromLoginPage;FormsAuthenticationTicket
- Laravel5.2 关于$errors变量的问题 form 表单验证
- asp.net 登陆验证 Form表单验证的3种方式 FormsAuthentication.SetAuthCookie;FormsAuthentication.RedirectFromLoginPage;FormsAuthenticationTicket
- java中multipart/form-data方式提交表单添加验证问题
- 关于请求方式为GET的form表单,action属性后不能带参数的问题
- 关于web中的session以及cookie验证的问题
- asp.net 登陆验证 Form表单验证的3种方式 FormsAuthentication.SetAuthCookie;FormsAuthentication.RedirectFromLoginPage;FormsAuthenticationTicket
- EXTjs中关于form验证,emptyText属性的问题
- 找到一篇关于form以post、get方式提交数据中文乱码问题总结
- 关于请求方式为GET的form表单,action属性后不能带参数的问题
- 单点登录(十一)-----遇到问题-----cas启用mongodb验证方式报错--Unable to locate Spring NamespaceHandler for XML schema na
- 关于验证控件和javaSript验证的共存问题
- 关于Android Menu横纵向显示的问题(经过验证)
- 关于Windows Media Player11需验证问题的解决