Created
November 27, 2018 10:27
-
-
Save monir-dev/a953a36d1e9fa2f929ac5ebc5b26d091 to your computer and use it in GitHub Desktop.
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 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. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
or use this plugin: https://www.paulirish.com/2009/jquery-idletimer-plugin/