This article shows how to display an alert message and prompt the user whether he wants to extend the session. If the user clicks OK, then it will automatically increase the session, else it will close the session with a warning message.
You can also change and update the code based on your requirements, this is just sample to show how to extend the session and show a timed-out alert message.
<script language="javascript" type="text/javascript">
AlertTimeOut = 0.25 * 60 * 1000;
WarnTimeOut = 0.25 * 60 * 1000;
setTimeout("WarnUser();", WarnTimeOut);
function AlertUser()
{
alert('Your session has been expired, please save your data outside the system [copy the data in word document].');
}
function WarnUser()
{
var currentTime = new Date()
var hours = currentTime.getHours()
var minutes = currentTime.getMinutes()
if (minutes < 10){
minutes = "0" + minutes
}
if(hours > 11){
var tempTime = hours + ":" + minutes + "PM"
} else {
var tempTime = hours + ":" + minutes + "AM"
}
var ans = confirm("Your login session is about to expire in 5 minutes.Do you want to extend it? - Date: " + tempTime);
if (ans)
{
var oImage = new Image;
oImage.src = "tempdummy.gif" + Math.random();
setTimeout("WarnUser();", WarnTimeOut);
}
else
{
setTimeout("AlertUser();", AlertTimeOut);
}
}
</script>