Detecting when a Session has expired

Results 1 to 3 of 3

Thread: Detecting when a Session has expired

  1. #1
    Bill Anthony Guest

    Default Detecting when a Session has expired

    Greetings to everyone.<BR><BR>I appreciate all the assistance I have received in the past from fellow developers within this thread community. Today, I have a new question that someone might have experience in and can provide a clear, logical answer.<BR><BR>I am designing a web application that will be rolled out to insurance representatives who, quite frankly, have little time to waste using the web app to begin with (don&#039t ask). Anyway, the possibility might arise where, a rep will begin using the app, hence, initializing the web Session; then, he/she might become involved in fielding a sales call, playing solitaire, etc. The time spent on the sales call or card game might exceed the default Session timeout setting. If the Session has timed out, the rep can continue in the middle of the web app as if nothing happened and create a new SessionID with the introduction of new browser activity. If this occurs, anything the rep might have processed prior to their sales call or solitaire game will be lost in the Session timeout. I already understand that you can modify the session timeout and make it larger, however, this is not the answer for me because we do not want to maintain the session for extended periods of time. We prefer to use the default 20 minutes.<BR><BR>Here is my question: Is there a way in which I can script to detect if the session has timed out and, if it has, notify the client and redirect him/her to start the web app again from the beginning? <BR><BR>The reason I need this done is because I am capturing session variables from page to page and, on the final submit page, I am performing the ADO push to the database. If a rep loses the session in the middle of the app and continues later, we only capture what has been processed when the rep returns to finish the app.<BR><BR>Any thoughts or ideas will certainly be helpful, as always!<BR><BR>Thanks a bunch!<BR><BR>Bill Anthony

  2. #2
    Join Date
    Dec 1969

    Default RE: Detecting when a Session has expired

    In Session_OnStart, create a session variable, something like:<BR><BR>Session("SessionActive") = "No",<BR><BR>then, in all of your pages (except default.asp), put:<BR><BR>Then, at the top of each of your pages, put:<BR>&#060;% If Session("SessionActive") = "No" then<BR>Session("SessionActive") = "Yes"<BR>Response.Redirect "/default.asp"<BR>End if %&#062;<BR><BR>In default.asp, put:<BR>&#060;% Session("SessionActive") = "Yes" %&#062;<BR><BR>So, if the session expires, Session("SessionActive") will be reset to "no" when they access the page again (since Session_OnStart will refire). So, if they access the web app at any page, but have not gone through the default.asp, OR if their session has timed out, they will be redirected to default.asp. Make sense?

  3. #3
    Jason Buck Guest

    Default RE: Detecting when a Session has expired

    Assign your session a variable/strname.<BR><BR>Create an include file checksession.asp.<BR><BR>On all of your pages &#060;!--#include virtual="/include/checksession.asp" --&#062;<BR><BR>The code for you include file is the following:<BR><BR>&#060;%<BR>Dim strCheckSession<BR>strCheckSession = Session.Contents("strSession")<BR>Response.Expires Absolute = Now() -1<BR><BR>if Len(strCheckSession) = 0 Then<BR> <BR> response.redirect "default.htm"<BR>End if<BR>%&#062;<BR><BR>Basically what this does is if the session Expires, and the user tries to go to any other page it will redirect them to your default page. Then they will have to start over.<BR><BR>Respectfully,<BR><BR>Jason<BR>webmast<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts