-
Notifications
You must be signed in to change notification settings - Fork 0
JS session management
illyfrancis edited this page Mar 5, 2014
·
15 revisions
http://stackoverflow.com/questions/16329055/javascript-rest-client-and-session-management
http://stackoverflow.com/questions/6068113/do-sessions-really-violate-restfulness
http://stackoverflow.com/questions/319530/restful-authentication?lq=1
How to detect session timeout while working in client?
One approach might be to periodically 'ping' the server in the background where the 'period' is less than the session timeout period set on server. from SO
The basic example:
setInterval(function(){
$.get('/ImStillAlive.action');
}, 840000); // 14 mins * 60 * 1000
With basic check for typing activity:
$(function(){
var lastUpdate = 0;
var checkInterval = setInterval(function(){
if(Date().getTime() - lastUpdate > 840000){
clearInterval(checkInterval);
}else{
$.get('/ImStillAlive.action');
}
}, 840000); // 14 mins * 60 * 1000
$(document).keydown(function(){
lastUpdate = new Date().getTime();
});
});
http://stackoverflow.com/questions/1296421/rest-complex-applications/1297275#1297275