Skip to content

Instantly share code, notes, and snippets.

@monir-dev
Created November 27, 2018 10:27
Show Gist options
  • Save monir-dev/a953a36d1e9fa2f929ac5ebc5b26d091 to your computer and use it in GitHub Desktop.
Save monir-dev/a953a36d1e9fa2f929ac5ebc5b26d091 to your computer and use it in GitHub Desktop.
var IdleTime = 0;
setTime();
$(this).on("mousemove keypress", function () {
IdleTime = 0;
});
function setTime() {
setTimeout(function () {
IdleTime += 1;
console.log(IdleTime + " Second passed.");
checkTime();
}, 5000);
}
function checkTime() {
if (IdleTime <= 2)
setTime();
else
console.log('Session Timeout!!!! ' + IdleTime);
// reference ajax function here.
}
@monir-dev
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment