Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to increase session timeout time in Asp .Net MVC 5? [duplicate]

Application logout automatically in few seconds, i want to increase it to 30mins.

I have done some code in web.config file but it doesn't work. i have researched many articles on it but i could not resolve it.

Web.config code :

<sessionState mode="InProc" timeout="1800"></sessionState>
    <authentication mode="Forms">
      <forms loginUrl="~/Login" timeout="1800">
      </forms>
    </authentication>
like image 243
Manish Tiwari Avatar asked Aug 13 '16 14:08

Manish Tiwari


1 Answers

Session State & Authentication timeouts are in minutes not seconds. So, you should have

<sessionState mode="inProc" timeout="30" ></sessionState>
<authentication mode="Forms">
      <forms loginUrl="~/Login" timeout="30">
      </forms>
</authentication>

Also, you should be aware that the way this is setup, the authentication will timeout 30 minutes after it was granted while the session will extend the 30 minutes to be from last access. To make these two closer to syncing up, you should add slidingExpiration="True" to the forms element.

If, after these changes, it is still logging you out after a few seconds, take look at:

  1. Is the cookie getting created in the website? It's name will be .ASPXAUTH and it should be a session cookie.
  2. Are you closing the browser when the timeout occurs?
  3. Do you have multiple applications using the same authentication method?
like image 56
Jeff Siver Avatar answered Sep 28 '22 04:09

Jeff Siver