Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.
There are a few ways to do this. Here are a couple...
set a session expiry time, such that after a certain amount of time, the session expires and is no longer valid.
set a time flag as session data, and check if their session is still new enough to keep them logged in each pageload.
since Php is server side, there are no way to check it unless a page reload or an ajax calland you can always save a time stamp in $_sessions or $_cookie for checking later on, and have a call in jQuery like so
function CHeckLogedin(){
$.get('checklogin.php', {}, function(returndata){
if(returndata == 'true'){
//user still logged in
alert('you are still logged in');
} else {
//user logged out
window.location='signin.php';
});
}
next in checklogin.php page
do something like
<?
start_session();
$next5min = strtotime('+5 minute');
if ($_SESSION[time] < $next5min){
echo 'true';
} else {
echo 'false';
}
?>
and whenever user moves between pages change his $_SESSION[time] to time(), so its always updatedand in whichever page you wanna have that check do something like
setTimeout(CHeckLogedin(),);
i haven't tested this code, so it might have some bugs
Hope that helped,have a good day.