Forum Moderators: coopster
Here's the code, the unexpected T_VARIABLE error lies on $c_min
if($logged_in == 1)
{
$refresh_time = 1;
$c_hour = date('H'); //Current Hour
$c_min = date('i'); //Current Minute
$c_sec = date('s'); //Current Second
$c_mon = date('m'); //Current Month
$c_day = date('d'); //Current Day
$c_year = date('Y'); //Current Year
$timestamp = mktime($c_hour,$c_min,$c_sec,$c_mon,$c_day,$c_year);
$old_timestamp = $_SESSION['timestamp'];
if ($oldtime & $timestamp > $old_timestamp)
{
unset($_SESSION['username']);
unset($_SESSION['password']);
// unset session variables
$_SESSION = array(); // reset session array
session_destroy(); // destroy session.
header('Location: login.php');// redirect to login
die;
} else {$_SESSION['timestamp'] = mktime($c_hour,$c_min+$refresh_time,$c_sec,$c_mon,$c_day,$c_year);} // update the timestamp
?>
<h1>Logged in</h1>
<p>Welcome <? echo $_SESSION['username'];?></p>
<a href="logout.php">logout</a>
<?
die;
}
Thanks in advance ;)
You don't mention what line it says the error is on but ...
if ($oldtime & $timestamp > $old_timestamp)
looks a little strange, not quite sure what you are tryin to do there. Is it supposed to be a + or do you want to compare both?
<added>alright you did mention it I just didn't read the desc ;)
why not just
$timestamp = mktime();
[ca.php.net...]
Arguments may be left out in order from right to left; any arguments thus omitted will be set to the current value according to the local date and time.
therefore, if you leave them all out you get NOW.
amd you shouldn't need to redo the mktime here
$_SESSION['timestamp'] = .....
since you could do
$_SESSION['timestamp'] = $timestamp;
you already got it earlier and can reuse it.
Now when i think of it it is always going to contain a value so I'm removing it from the if statement but the problem still remains.