Created
April 16, 2018 01:19
-
-
Save MateusAndreatta/a617e164da2065e9d1d3cee457cb16f4 to your computer and use it in GitHub Desktop.
Script de time out, para encerrar a sessao do usuario
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var n = 0; | |
//Reiniciar o contador em qualquer ação do usuario | |
document.onclick = function() { | |
n = 0; | |
}; | |
document.onmousemove = function() { | |
n = 0; | |
}; | |
document.onmousedown = function() { | |
n = 0; | |
}; | |
document.onscroll = function() { | |
n = 0; | |
}; | |
document.onkeypress = function() { | |
n = 0; | |
}; | |
document.onmousemove = function() { | |
n = 0; | |
}; | |
window.setInterval(function() { | |
if (n > 180000) {//tempo em milissegundos para trocar de pagina | |
window.location = "suapagina.php";//redireciona para suapagina.php | |
window.document.write("<?PHP session_destroy();?>"); //encerrar a sessao do usuario | |
} else { | |
n = n + 1000; | |
} | |
}, 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment