Make a session expire

Asked

Viewed 66 times

0

I am trying to put on my page that if the visitor becomes 20 minutes inactive, the session expires, php destroys the session and redirects the visitor to the login page. But it’s not working. My code is like this:

session_start();
$_SESSION['inicio'] = time();
$_SESSION['final']  = $_SESSION['inicio'] + (1 * 60) ;
$agora               = time();
if(isset($_SESSION['final'])){
    if($agora > $_SESSION['final']){
      session_destroy();
      header("Location: ../index.php?id=998&tp=bi");
      }
    }

1 answer

1

Doesn’t it get easier you do so? I use this way on my websites..

header("Refresh: 1200; url=paginadelogin.php");

Hug!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.