session_destroy() after certain amount of time in PHP

后端 未结 2 1275
闹比i
闹比i 2020-12-11 12:07

I am currently saving a session in my form page:

$testingvalue = "SESSION TEST";

$_SESSION[\'testing\'] = $testingvalue;

2条回答
  •  借酒劲吻你
    2020-12-11 12:37

    Something like this should work

     $inactive)) {
        // last request was more than 2 hours ago
        session_unset();     // unset $_SESSION variable for this page
        session_destroy();   // destroy session data
    }
    $_SESSION['testing'] = time(); // Update session
    

提交回复
热议问题