There was a requirement in my project to notify the user of session expiry before it expires. I have implemented this in jquery using setTimeout. Its working fine till user is working in a single tab. The problem arises if multiple tabs are kept opened. In this case, even though user is working on a tab since other tabs are inactive alert is being displayed on those inactive tabs. This should not happen because user is active on one tab.
I am using something like below code:
function SessionExpireAlert() {
var timeout = 20000;
var seconds = timer / 1000;
document.getElementsByName("seconds").innerHTML = seconds;
setInterval(function () {
seconds--;
document.getElementById("seconds").innerHTML = seconds;
},1000);
setTimeout(function () {
//Show Popup before 20 seconds of timeout.
$find("mpeTimeout").show();
}, timeout - 19 * 1000);
setTimeout(function () {
window.location = "Default.aspx";
}, timeout);
};
function ResetSession() {
//Redirect to refresh Session.
window.location = window.location.href;
}
function ResetTimers() {
clearTimeout(seconds);
SessionExpireAlert
}
I will be happy for any suggestion in this...