Reputation: 253
I need your help in getting the appropriate code for showing the count down for the session time out in the progress bar or any part of the screen.
However, these actions should be included:
First Alert: "You have 5 minutes before your session expires" Click here to continue your session. or Click here to logout
if no action in 5 mins then change the page to display "Your session has expired" and will be redirected to logout.jsp.
I tried to find good examples, but I did not find anyone.
Can anyone help on that issue.
Upvotes: 1
Views: 11218
Reputation: 10595
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<script type="text/javascript">
var timeoutHandle = null;
function startTimer(timeoutCount) {
if (timeoutCount == 0) {
window.location.href = 'logout.jsp';
} else if (timeoutCount < 3) {
document.getElementById('sessionTimer').innerHTML = 'You have ' + (timeoutCount * 3000)/1000 + 'seconds until timeout' ;
}
timeoutHandle = setTimeout(function () { startTimer(timeoutCount-1);}, '3000');
}
function refreshTimer() {
killTimer(timeoutHandle);
startTimer(3);
}
</script>
</head>
<body onload="startTimer(3)">
<div id="sessionTimer"></div>
</body>
</html>
Upvotes: 6