Reputation: 17
I'm trying to make an error session that expires after 10 seconds but using the method i followed it just always unset the session even before the 10 seconds.
First file of action action.php here is the error code for the session that i created
if(!$form)
{
$_SESSION['error']="L'email du contrôleur n'existe pas.";
$start_e=$_SESSION['start_e']=time();
$_SESSION['expire_e']=$_SESSION['start']+10;
header("location:../nsf-sfe.php");
}
and here the page.php where i check if the session is expired or not.
if($now >= $_SESSION['expire_e'])
{
unset($_SESSION['error']);
}
else {
//code
}
Upvotes: 1
Views: 60
Reputation: 17
I forgot to write $_SESSION['start_e'] correctly and now it's okay.
so now it's like
if(!$form)
{
$_SESSION['error']="L'email du contrôleur n'existe pas.";
$start_e=$_SESSION['start_e']=time();
$_SESSION['expire_e']=$_SESSION['start_e']+10;
header("location:../nsf-sfe.php");
}
and it works.
Upvotes: 1
Reputation: 2447
increase the time like below
$time = date("m/d/Y h:i:s a", time() + 10);
in place of this
$start_e=$_SESSION['start_e']=time();
$_SESSION['expire_e']=$_SESSION['start']+10;
Upvotes: 1