AllExperts > Experts 
Search      

Active Server Pages Programming (ASP)

Volunteer
Answers to thousands of questions
 Home · More Questions · Answer Library  · Encyclopedia ·
More Active Server Pages Programming (ASP) Answers
Question Library

Ask a question about Active Server Pages Programming (ASP)
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Jeff Allen
Expertise
I can answer basic to intermediate questions related to Classic ASP.I can answer Intermediate to Advanced questions CSS& HTML, and basic questions about JavaScript and Ajax. I can also answer questions related to web page accessibility under US Section 508.

Experience
I have 8 years experience with HTML. I have been developing in ASP, VBScript and CSS for two years each. I also currently work as web developer.

Organizations
IWA-HWG

Education/Credentials
I have a BA in English with minors in Web Design and Scientific and Technical Writing

 
   

You are here:  Experts > Computing/Technology > Business Software > Active Server Pages Programming (ASP) > Session time out

Topic: Active Server Pages Programming (ASP)



Expert: Jeff Allen
Date: 11/7/2006
Subject: Session time out

Question
If I set session timeout to 10 min.  It will automatically ends the session.  But I want to give alert message to user with OK and Cancel buttons.  If he clicks OK it will keep the session alive.  If he clicks cancel it will drops the session.


-------------------------------------------
The text above is a follow-up to ...

-----Question-----
In my application we don't have session timeout.  Now we want to implement it. If the user has not accessed the application or not triggered any every for certain period of time(for ex: 10 min) then I want to show a message asking user to continue the session or not.  If user wants to continue I need to reset the timeout variable other I need to redirect the control to Login form.

Could you please tell me in what way I can do this in ASP

-----Answer-----
In Classic ASP you'd set the Session.Timeout for 10 minutes. Normally, by default it is set for 20 minutes. You'd set it like so: Session.Timeout (= intMinutes) so, to set it for ten minutes you would just use Session.Timeout = 10 to set the timeout to 10 minutes.


Answer
I'm not sure if you can do this using ASP or not but you can do it using client-side JavaScript very similar to this:

<script language="javascript" type="text/javascript">

var lTime=29*60;
function LogoutTimer() {

lTime=lTime-1;

var lMins=(lTime-(lTime%60))/60;
var lSecs=lTime%60;

window.status="Auto Logout: " + lMins + " Min " + lSecs + " Sec" ;

//5 min warning
if (lMins==5 & lSecs==0) {
alert('You will be automatilly logged out in 5 minutes. Please save you work now to ensure no work is lost.');
}

//timeout warning
if (lMins==0 & lSecs==0) {
alert('You session has timed out. You will need to login again. Please make a copy of your work before you do anything else as it may be lost.');
}

}

window.setInterval("LogoutTimer()",1000);
LogoutTimer();

</script>

Add to this Answer    Ask a Question



  Rate this Answer
   Was this answer helpful?
Not at allDefinitely              
   12345  

     
About Us | Advertise on This Site | User Agreement | Privacy Policy | Help
Copyright  © 2008 About, Inc. About and About.com are registered trademarks of About, Inc. The About logo is a trademark of About, Inc. All rights reserved.