I have been investigating about the closing of sessions due to inactivity in my page, I have achieved it with the following code in my main page (index.php):
script
<script>
function idleLogout() {
var t;
window.onload = resetTimer;
window.onmousemove = resetTimer;
window.onmousedown = resetTimer; // catches touchscreen presses
window.onclick = resetTimer; // catches touchpad clicks
window.onscroll = resetTimer; // catches scrolling with arrow keys
window.onkeypress = resetTimer;
function logout() {
window.location.href = 'logout.php';
}
function resetTimer() {
clearTimeout(t);
t = setTimeout(logout,140000); // time is in milliseconds
}
}
idleLogout();
</script>
and I pass the function in body to index.php
<body onunload="idleLogout()">
logout.php (I destroy the session)
<?php
session_start();
session_destroy();
header( "Location:session_expire.php" );
?>
But my index.php has features that open in NEW WINDOWS, then, when I stop interacting in index.html because I'm in those windows, what to do to have this session time reset, since close my session