session active PHP, check in LOOP?

时间:2018-05-18 17:14:16

标签: php session

I have this function which I am using at the beginning of every of my PHP pages, which is working fine, if time has expired, the next CLICK on the page it will go out fine and go to usuarioLoginLogout.php.

function verificarSiEstoyConectado()
{
    if( $_SESSION['last_activity'] < time()-$_SESSION['expire_time'] )
    {
        header('Location: usuarioLoginLogout.php');
    }
    else
    {
        $_SESSION['last_activity'] = time();
    }
}

In my welcome page, I'm settings session variable as follows:

$_SESSION['logged_in']     = true;
$_SESSION['last_activity'] = time();
$_SESSION['expire_time']   = 60*3;

My doubt is if exists any way to check that function but in a LOOP, not to wait to the user to do click in any link of my site in order to check at the beginning of any page that if has expired or not?

If it possible, how could I implement this?

Thanks in advance,

0 个答案:

没有答案