Automatic Logout after 15 minutes of inactive in php

后端 未结 8 785
悲&欢浪女
悲&欢浪女 2020-12-04 15:51

I want to destroy session if users are not doing any kind of activity on website. At that time after 5 users automatically redirect on index page. How is it possible? Is pos

8条回答
  •  旧巷少年郎
    2020-12-04 16:34

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

提交回复
热议问题