A session that never ends, for example, at stackoverflow.com, if the user does not log out

I am creating an asp.net mvc application. I want the session to never expire as soon as the user is logged in, unless the user clicks on logout.

What is the best way to do this?

I used

FormsAuthentication.SetAuthCookie(userName, createPersistentCookie);

and set createPersistentCookie to true, but still I'm logging out after a while.

+3
source share
2 answers

Enter the sliding ending. Leave the validity period to a reasonable value - a day, two, maximum weeks; update the cookie for each request (simplest) or at certain intervals.

+6
source

cookie FormsAuthentication . createPersistentCookie API expires, cookie, . , web.config. , cookie , 525600.

+1

Source: https://habr.com/ru/post/1754926/


All Articles