Make a session expire

0

I'm trying to put on my page that if the visitor stays 20min inactive, the session expires, php destroys the session and redirects the visitor to the login page. But it's not working. My code looks 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");
      }
    }
    
asked by anonymous 16.11.2018 / 23:31

1 answer

1

Is not it easier for you to do this? I use this way on my sites ..

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

Hugs!

    
17.11.2018 / 13:51