Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

asp session problem

Status
Not open for further replies.

xenomage

Programmer
Jun 27, 2001
98
SG
Hi all,

had this problem for a long long time.

Is it possible to obtain an event just before the session time out and then let user select whether to end the session or continue??

i know there is an On_End event but once it reach on end , all the session variables will be lost already right??

Please help. Any suggestion are appreciated.

xenomage
 
A solution I thought of (may not be the best) is to set a timeout on a piece of JScript that pops up an alert box telling the users session is about to expire.
 
In JavaScript..
Code:
<head>
<script language=&quot;JavaScript&quot;>
<!--
setTimeout(&quot;sessionAlert()&quot;,60000)
var sWin
function sessionAlert() {
  if(window.confirm(&quot;You're session is about to expire.  Would you like to keep your session open ?&quot;) {
    if(sWin && !sWin.closed) {
      sWin.close()
    }
    sWin = window.open(&quot;somepage.asp&quot;,&quot;sw1&quot;,&quot;width=300,height=300&quot;);
  }
}
//-->
</script>
</head>
You need to provide three values to this script. The timeout (currently set to 60,000 or one minute) length which needs to be in milliseconds. The timeout value is the amount of time that elapses before the confirm message appears on the screen. So if your ASP session times out in 60 minutes and you wanted to give the visitor 10 minutes advanced notice, then you would set the timeout in this JavaScript for 50 minutes or 3,000,000. Of course, leave the commas out in your script.

The text in the confirm box which alerts the user.

And a small confirmation page in ASP telling the user that the session has been refreshed. When that page is loaded into the browser, ASP will automatically reset the session timeout.

ToddWW

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top