0

I am currently following this guide: https://samjlevy.com/php-ldap-login/

It all works great and the login script works fine. Only what I want to do is insert a simple piece of code that the session times out in like 30 minutes or something and than the user automaticly logs out.

How can I archieve this

klaas123
  • 147
  • 1
  • 10

1 Answers1

0

Please try this code.

          session_start();
          $t=time();
          if (isset($_SESSION['logged']) && ($t - $_SESSION['logged'] >1800)) {
          session_destroy();
          session_unset();
          header('location: index.php');
          }else {$_SESSION['logged'] = time();}