I'm using the JavaScript below to check if the user session has not expired (with PHP) at intervals of 5 seconds. After logging out from another tab (same browser) or which the current session must have expired, still the code is bringing up the alert("Logged back in.");
which is supposed to work for active sessions.
setInterval(function () {
var checklogin = "<? if ($this->session->userdata('user_logged_in')) {echo '1';} else {echo '0';} ?>";
if (checklogin == "1" ){
alert("Logged back in.");
} else {
alert("you are already logged out!");
}
}, 5000);
Please what am I doing wrong ?