c# - Increase timeout of an already started session -


i want add "keep me logged in" option custom login control.

this how i'm using session: i'm saving , reading values httpcontext.current.session["key"] manually. works fine.

relevant parts of web.config:

<sessionstate mode="stateserver" usehostingidentity="true" cookieless="false" timeout="120" stateconnectionstring="tcpip=127.0.0.1:42424" /> <authentication mode="forms">   <forms loginurl="/login" name="authcookie" timeout="120" slidingexpiration="true" path="/" /> </authentication> <authorization>  <allow users="*" /> </authorization> 

as can see, default duration of session 120 minutes.

"logout":

  session.clear();   session.abandon(); 

through custom login control textboxes, grant access member area. (i don't use system.web.security.formsauthentication)
after entering valid credentials , checked checkbox "keep logged in", want increase duration of active session ~30 days.

so far i've found solutions like

formsauthenticationticket fat = new formsauthenticationticket(1, "username", datetime.now, datetime.now.addminutes(1), false, "username"); string encticket = formsauthentication.encrypt(fat); response.cookies.add(new httpcookie(formsauthentication.formscookiename, encticket) { expires = fat.expiration }); 

which don't work, because system.web.security.formsauthentication.timeout still @ 120 minutes. same goes setting

session.timeout = 666; 

any suggestions?

you can't approach way. can't persist session on days - it's not going scale well.

what people provide means automatic login, when session expires, seamlessly logged in on next action/reload. people cookie contains unique hash, checked @ server. if want person logged in 30 days, set cookie expire in 30 days time.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -