views:

717

answers:

4

Hello everyone,

My question is about classic ASP, not ASP.Net. I ask expert here since search engine always tell me ASP.Net answers. My confusions are,

  1. How to set session expiration time in classic ASP code or through configuration?
  2. How to extend session expire time? Is there a session expire event?
  3. How to know when session will expire?

thanks in advance, George

+3  A: 

George, ASP Classic sessions timeouts were finicky at best. I wouldn't rely on them. If you need to have more control over sessions I suggest you implement your own session management.

Spencer Ruport
I am interested in what you mean -- "finicky at best"? Share some more insights and experiences? Currnetly I am maintaining some legacy code written by classic ASP, there is headache session expire issues...
George2
Take a look: http://www.google.com/search?client=firefox-a)
Spencer Ruport
Is there a way to know when session will expire?
George2
+5  A: 

Please read this, I think it answers all your questions:

http://www.w3schools.com/ASP/asp_sessions.asp

George,

There is a session_end event on the server side, but I suppose what you want is to detect it on client side.

To do that, you must set a timer on javascript, to end for example one minute before the session timeout and popup an alert. The alert gives the user the choice to extend the session. If the user says yes, then you make a post of the form (or an ajax call or anything that generates a request on the server side and so extends the session).

tekBlues
Seems not session end event and solutions to extend an expired session?
George2
Thanks for your update, 1. could we extend session at server side when session expire? 2. "If the user says yes, then you make a post of the form (or an ajax call or anything that generates a request on the server side and so extends the session)." -- I do not want a solution which will force user to leave the page, I want to extend user session while at the same time let user retain to the same page to continue actions (e.g. editing a long document). Any ideas how to do this?
George2
The ajax call he is talking about, would not force you to leave the page. You just need to generate some traffic to the site before your session expires so you can reset the timeout (now + 20 minutes).
Zachary
@Zachary, appreciate if you could refer me some ready-to-use ajax samples. I did not got too much ideas about this solution until I see some workable code.
George2
+1  A: 

Session.Timeout = 5 'five minutes

The session will expire after the number of minutes you've specified with no activity. For instance, if you set a session variable, and the user doesn't do anything (like refresh) for 5 minutes, then the session will be abandoned by the server.

Or, you can abandon it yourself using Session.Abandon

mgroves
Is there a session end event? Could we extend session expire time?
George2
Dont think you can find out when the session is going to expire bcos if say for ex. if the session timeout is 20 mins and the user is inactive for a period of say 19 mins and only 1 min is left and he/she clicks on the app, the session is valid for 20 mins more since it was activated.
chugh97
There might be a session end event in the Global.asa, but I'm not sure.
mgroves
I find it, on session end event.
George2
+1  A: 

Dont think you can find out when the session is going to expire bcos if say for ex. if the session timeout is 20 mins and the user is inactive for a period of say 19 mins and only 1 min is left and he/she clicks on the app, the session is valid for 20 mins more since it was activated.

chugh97
What I mean is, is it possible to know when if user does not active operate on the page, when (i.e. how much idle time left) session will expire?
George2
Thats what I have mentioned..It is hard to find that out but have heard that you can use AJAX to ping back the server...dont know exactly how to achieve it...
chugh97
Have a look at this linkhttp://radio.javaranch.com/pascarello/2005/07/05/1120592884938.html
chugh97
Looks like an interesting article :http://www.pascarello.com/AjaxSessionTimer.aspx
chugh97