Resources | ASP | Session.Timeout

Session Timeouts:


For IIS Servers, there is a specific amount of time before a user's Session is timed out (by default, this time is set to 20 minutes). Once the Session times out, your Session variables get cleared out, which can create quite a few problems. You can change the default for an application by setting the Session Timeout property on the Application Options property sheet in Internet Service Manager. You can also do it through ASP code:


However, this is not a great solution. Although there is no maximum value you can set for the timeout value, if the setting is too long it can hog up the Server's resources and slow everything down.

A good solution to this problem is to give your users a warning that they are about to be logged out by the server. Upon receiving this notice, they can take action to maintain their session state. You can use this combination of ASP and JAVASCRIPT to give them a warning:


Besides your Session, there are a few other objects that can Timeout. Here is the code to lengthen the Timeout period for these objects:

Server.ScriptTimeout (The length of time an ASP script is allowed to run on the server)


ConnectionObject.connectionTimeout


CommandObject.commandTimeout

Update:

I've gotten a few questions asking about the maximum values for various Timeouts. On an IIS Server, any value can be set for these Timeout properties (using the ASP scripts detailed above). However, just because you can set the value to a very high value doesn't mean that you should! If your code is extremely processor-intensive (or if there is some code on your page causing an infinite loop) you can eventually tie up all your Server's system resources if the timeout value isn't a reasonable value.

One more note: The minimum value for these Timeout properties is 1 second.


Want to discuss this article, or other development issues? Visit our message boards!

Or contact us directly with a comment or question on this article: click here !
armbrustconsulting.com