Lucky Luke2 Lucky Luke2 - 1 year ago 314
ASP.NET (C#) Question

Forms authentication timeout vs sessionState timeout

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" />

<sessionState timeout="30" />

Does anyone know if one takes precedent over the other, and how they are different. Thanks.

Answer Source

They are different things. The Forms Authentication Timeout value sets the amount of time in minutes that the authentication cookie is set to be valid, meaning, that after value number of minutes, the cookie will expire and the user will no longer be authenticated - they will be redirected to the login page automatically-. 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, they will continue to be authenticated. If you set slidingExpiration=false the authentication cookie will expire after value number of minutes regardless of whether the user makes a request within the timeout value or not.

The SessionState timeout value sets the amount of time a Session State provider is required to hold data in memory (or whatever backing store is being used, SQL Server, OutOfProc, etc) for a particular session. For example, if you put an object in Session using the value in your example, this data will be removed after 30 minutes. The user may still be authenticated but the data in the Session may no longer be present. The Session Timeout value is always reset after every request.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download