I'm using a timer function to check if the session is valid or not every five seconds.
setInterval(checksession,5000);
function checksession(called_for) {
//alert('check-session')
$.ajax({
type:'POST'
,url:'CheckSession'
,success: validateresult
,data: { antiCSRF : '{{acsrf}}',
session_id: '{{session_id}}'}
//,error: function(){ alert('Session check failed') }
})
}
I would like to know what will happen if I have multiple ajax calls at the same time when the session is checked. Will it be 2 separate threads?
Is this the correct way to check session?
5000!= "10 seconds"... It's also really unclear what you mean by "check session". Nothing about the usual definition of "sessions" involves sending a keep-alive every 10 seconds. If your session does time out after 10 seconds (none of them do, ever, because that would be useless), then sending a keep-alive in JavaScript defeats the purpose of having your session time out. I've voted to close as "primary opinion based", because nobody is going to be able to tell you if this is the "correct way to check session", because you haven't defined what that means.