c# - FormsAuthenticationTicket.expiration v web.config value timeout -


this mvc2 website, having problem formsauthentication ticket. user timeouts after 30 minutes cannot re-login. during testing, datetime.now.addminutes(30) value set 5000 , ok, has changed 30 , when problem started

from cookie creation

 formsauthenticationticket ticket = new formsauthenticationticket(             1,             user.userid,             datetime.now,             datetime.now.addminutes(30),             false,             "user,user1",             formsauthentication.formscookiepath); 

web.config file

<authentication mode="forms">   <forms loginurl="~/account.mvc/logon" timeout="2880" name=".aspxformsauth" /> </authentication> 

does expiration value in ticket creation need >= web.config value?

because manually creating authentication cookie, timeout value in web.config ignored. recommend having same value:

var ticket = new formsauthenticationticket(     1,     user.userid,     datetime.now,     datetime.now.addminutes(formsauthentication.timeout.totalminutes),     false,     "user,user1",     formsauthentication.formscookiepath ); var encryptedticket = formsauthentication.encrypt(ticket); var cookie = new httpcookie(formsauthentication.formscookiename, encryptedticket) {     httponly = true,     secure = formsauthentication.requiressl,     path = formsauthentication.formscookiepath,     domain = formsauthentication.cookiedomain }; response.appendcookie(cookie); 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -