-
Session Timeout
Hi all,
I have a login script in ASP and would like to have a JS message box popup when the users session is about to time out.
So if i have a fixed session of 20min I would like to warn them when there is only 2 mins left before the session times out.
Can this be done?
-
OK here is what i ended up with
<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>