I\'ve found https://github.com/travishorn/jquery-sessionTimeout this jquery session timeout that I want to use in my project.
It looks work fine in background, altou
Try this
var SessionTime = 10000;
var tickDuration = 1000;
var myInterval = setInterval(function() {
SessionTime = SessionTime - tickDuration
$("label").text(SessionTime);
}, 1000);
var myTimeOut = setTimeout(SessionExpireEvent, SessionTime);
$("input").click(function() {
clearTimeout(myTimeOut);
SessionTime = 10000;
myTimeOut = setTimeout(SessionExpireEvent, SessionTime);
});
function SessionExpireEvent() {
clearInterval(myInterval);
alert("Session expired");
}
See this jsFiddle example.