Posts Tagged ‘Timeout’

ASP.NET Sessions Part 5 – How Long Does a Session Last?

Thursday, March 12th, 2009
This entry is part of a series, ASP.NET Sessions»

Bearing in mind what I posted in earlier parts of this series of posts on sessions, you may find that other factors cut short your users’ sessions – see the earlier posts about this.

You can set the timeout of your sessions using the “timeout” attribute of the “sessionState” element in web.config.  This is a value set in minutes, and is the idle time before a session expires.  That means that the time is measured from the last request (not sure if it is measured from when the request is started, completed or some random point in the middle).  It isn’t measured from the start of the session or anything. 

The maximum value is 525,600, which is the number of minutes in a year (assuming it is a non-leap year).  This maximum value apparently only applies to the in process and state server modes (I’ll be amazed if anyone manages to keep a session going that long in either of these modes without dedicating a server to it!).  

The default value is 20 minutes.

Note that changing this has absolutely no effect on classic ASP sessions – they operate completely independently.  I’m pretty sure nothing in web.config will ever really affect them.