I am currently saving a session in my form page:
$testingvalue = "SESSION TEST";
$_SESSION['testing'] = $testingvalue;
On another page I am calling the session to use the value:
<?php
session_start(); // make sure there is a session
echo $_SESSION['testing']; //prints SESSION TEST???
?>
Now I want to use the
session_destroy();
to destroy the session. But what I would like to do is destroy the session after 2 hours have been passed.
Any idea on how to do it and also where should I put it?
I have something like this:
 <?php
session_start();
// 2 hours in seconds
$inactive = 7200; 
$session_life = time() - $_session['testing'];
if($session_life > $inactive)
{  
 session_destroy(); 
}
$_session['testing']=time();
    
    echo $_SESSION['testing']; //prints NOTHING?
    ?>
Will that work?
If I am inactive for more than 2 hours this should be blank?:
echo $_SESSION['testing'];
 
     
     
    