views:

1676

answers:

2

Hello everyone,

I am using ASP classic (1.1) with IIS 6.0. Is there any options to set session never expire?

thanks in advance, George

+2  A: 
Session.Timeout=5

Would mean that it times out in 5 minutes. I don't think you can set this to infinity but you can set it to an approximately large number.

Travis
What is the maximum value I can set?
George2
"The minimum allowed value is 1 minute and the maximum is 1440 minutes." - http://msdn.microsoft.com/en-us/library/ms525473.aspx
Chris
+1  A: 

You can specify a Session.Timeout value in minutes. Or have your pages poll the server every n minutes (a javascript function would do that, or you can have a dummy iframe with refresh-content set to call a dummy asp page every n minutes).

This is better (albeit polling can be taxing on your server, don't poll too often) because if you set your session timeout to a very high (or infinite...) value you'll end up with asp crashing with an out of memory error (I guess the application pool will be restarted).

The session is kept alive when the user calls any asp page on your application before the timeout expires. If your user closes its browser, there's no way your app will be notified and asp will have to wait for the timeout to clean the memory. That means that the session will stay in memory for n minutes after the user is gone, n being the timeout.

There's no need to have an infinite session (it can be addressed by polling) and tweaking with the timeout parameter will make your application more fragile.

If you want to store information for a long while (basically, for the whole life of your application) you'd better use the Application object, which is a dictionary just like Session but is a singleton and can be accessed by anyone on the server.

Yann Schwartz
Thanks @Yann! 1. I want to confirm with you Application object never expires as session object? 2. I think the optimum way you suggest is to set a relatively short time out and refreshing the page by javascript or content refresh setting? And the reason is session memory will be freed at server side timely? My understanding correct? 3. "if you set your session timeout to a very high (or infinite...) value you'll end up with asp crashing with an out of memory error (I guess the application pool will be restarted)." -- caused by long timeout value which keeps session in server memory long?
George2
4. There is no way to set infinite value for expire time in ASP classic session (I mean ASP classic language and runtime does not support it directly)?
George2
Application gets cleared if and when the Application drops out of the application pool, if the site gets relatively low traffic it will drop out of the application pool and any data in the Application object is lost. If you want to persist anything there then you need to store in it a database or some other backend storage
RobV