Skip to content

Instantly share code, notes, and snippets.

@MateusAndreatta
Created April 16, 2018 01:19
Show Gist options
  • Save MateusAndreatta/a617e164da2065e9d1d3cee457cb16f4 to your computer and use it in GitHub Desktop.
Save MateusAndreatta/a617e164da2065e9d1d3cee457cb16f4 to your computer and use it in GitHub Desktop.
Script de time out, para encerrar a sessao do usuario
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