I am attempting to create a session ID for the user that lasts 1 hour.
User logins once - randomid generated - added to session.
User logins again within 1 hour, same Session ID applies.
If user logins after 1 hour, generate a new ID.
So far, I have this
session_start();
//create random sid
$today = date('YmdHi');
$startDate = date('YmdHi', strtotime('2012-03-14 09:06:00'));
$range = $today - $startDate;
$rand = rand(0, $range);
$sid= ($startDate + $rand);
//first time user
if(isset($_SESSION['sessionid'])) {
$_SESSION['sessionid'] = $sid;
}
//visiting user
else
{
$_SESSION['sessionid'] = $_SESSION['sessionid'];
}
echo $_SESSION['sessionid'];
How do I add a timeout for 1 hour? I have seen examples where cookies are used. I am hoping to be able to use only server-side sessions?
Any ideas?