|
Posted by Lee David on 05/27/05 00:49
Reformatted the code a little to fix a syntax error (if = = and not one).
Here is what comes before the <html>:
<?php
$lasthere = $_COOKIE[lasthere];
if (isset($lasthere))
{
// process existing cookie
$user = $_COOKIE[user];
// hour, minute, second, month, day, year
$lastupdate = mktime(16, 16, 16, 3, 26, 2005);
if ($lasthere < $lastupdate)
{
// updated stuff
$listnewstuff = "yes";
}
else
{
// old stuff
$listnewstuff = "no";
}
}
else
{
// get user name
$listnewstuff = "no cookie";
}
// in any case write a cookie out with the current date
setcookie("lasthere", time(), time() + 36000);
setcookie("user", "Kevin", time() + 36000);
?>
and I check the varibles with this:
<?php
echo "<br>lastupdate: " . date("M d, Y H:I:s", $lastupdate);
echo "<br>lasthere: " . date("M d, Y H:I:s", $lasthere);
echo '<br>now: ' . date("M d, Y H:I", time());
echo '<br>LNS: ' . $listnewstuff . '<br>';
if ($listnewstuff == "yes")
{
echo "new stuff to be found<br>";
}
else
{
echo "no new stuff to be found<br>";
}
?>
The output is this:
lastupdate: Mar 26, 2005 16:0:16
lasthere: May 26, 2005 14:1:36
now: May 26, 2005 14:1
LNS: no
no new stuff to be found
I hit it a few seconds later and got this:
lastupdate: Mar 26, 2005 16:0:16
lasthere: May 26, 2005 14:1:15
now: May 26, 2005 14:1
LNS: no
no new stuff to be found
the seconds change, but the minutes is still "0".
Navigation:
[Reply to this message]
|