I have code that i am looking through regarding session time outs of the website. In the web.config i came across this code.
<authentication mode="Forms">
<forms loginUrl="~/Auth/SignOn.aspx" timeout="40" slidingExpiration="true" />
</authentication>
<sessionState timeout="30" />
Does anyone know if one takes precedent over the other, and how they are different. Thanks.
This question is related to
asp.net
session
web-config
From what I understand they are independent of one another. By keeping the session timeout less than or equal to the authentication timeout, you can make sure any user-specific session variables are not persisted after the authentication has timed out (if that is your concern, which I think is the normal one when asking this question). Of course, you'll have to manually handle the disposal of session variables upon log-out.
Here is a decent response that may answer your question or at least point you in the right direction:
<sessionState timeout="2" />
<authentication mode="Forms">
<forms name="userLogin" path="/" timeout="60" loginUrl="Login.aspx" slidingExpiration="true"/>
</authentication>
This configuration sends me to the login page every two minutes, which seems to controvert the earlier answers
The difference is that one (forms time-out) has to do authenticating the user and the other( session timeout) has to do with how long cached data is stored on the server. So they are very independent things so one doesn't take precedence over the other.
The difference is that one (Forms timeout) has to do with authenticating the user and the other (Session timeout) has to do with how long cached data is stored on the server. So they are very independent things, so one does not take precedence over the other.
The slidingExpiration=true value is basically saying that after every request made, the timer is reset and as long as the user makes a request within the timeout value, he will continue to be authenticated.
This is not correct. The authentication cookie timeout will only be reset if half the time of the timeout has passed.
See for example https://support.microsoft.com/de-ch/kb/910439/en-us or https://itworksonmymachine.wordpress.com/2008/07/17/forms-authentication-timeout-vs-session-timeout/
For anyone stumbling across this question refer to this documentation from MS - it has really good details regarding FormsAuthentication Timeout setting.
This doc explains in detail about the comment bmode is making in the Accepted Answer - about the Persistent Cookie (Session vs Expires)
Source: Stackoverflow.com