The code you provided is using JavaScript to track user activity and display an alert message 1 minute before the session times out. However, it seems that the session timer is being reset even after the session has already timed out.
To fix this issue, you can modify the code to check if the session has already timed out before resetting the timer. Here's an updated version of the code:
var alertWinOpen = false;
var sessionTimeout = 10 * 60 * 1000; // 10 minutes in milliseconds
var inactiveTime;
function alertUserSession() {
if (alertWinOpen === false) {
OpenWindow();
}
}
function resetSessionTimer() {
clearTimeout(inactiveTime);
inactiveTime = setTimeout(alertUserSession, sessionTimeout);
}
$('*').bind('mousemove click mouseup mousedown keydown keypress keyup submit change mouseenter scroll resize dblclick', function () {
var pathname = $(location).attr('pathname');
if (pathname == '/login') {
return;
}
resetSessionTimer();
});
resetSessionTimer();
In this updated code, we define a sessionTimeout variable to store the session timeout duration in milliseconds. We also define a resetSessionTimer function that clears the previous timer and sets a new one.
The resetSessionTimer function is called both when the page loads and whenever there is user activity. This ensures that the session timer is reset only if the session has not already timed out.
Please note that this solution assumes you have a function named OpenWindow that displays the alert message. You may need to define this function or modify the code accordingly.
Remember to test the code thoroughly to ensure it meets your requirements.