Hi!
I've been working on this most of the day. Sometimes closer to success and sometimes far away. But I can't think clearly anymore so I post this for some luminous ideas
BG:
MySQL + PHP4
THE TASK:
I have a news system. Users can register and aside from some other goodies, they should be able to see only those news items that are new (counting from their last login).
THE PROBLEM:
If I store the "last login" in a cookie, and put the call for it on the top of the page just before I read from it I of course only get the time for this login but not the last.
If I read first from the cookie and then set a cookie for the next login, I just postpone the problem. If the user klicks refresh or goes on one of the sub-pages and then returns I will again only have the time of this login in the cookie.
I have tried sessions, and they look like the answer, but the same problem persists.
The sessionvariables change if the cookie is refreshed as soon as I reload the page.
This is what it looks now, but it doesn't work for me. Anyone have an answer on how to achive the TASK?
<PRE>
<?
if($visitor)
{
SetCookie("visitor",$visitor,time()-2864000);
SetCookie("visitor",$visitor,time()+2864000);
$my_id = $visitor;
}
else
{
$my_id = "0";
}
$datelog = date("YmdHis",time()+21600);
if($lastlog)
{
SetCookie("lastlog",$datelog,time()-2864000);
SetCookie("lastlog",$datelog,time()+2864000);
$to = $lastlog;
}
$tn = $to+3600;
if ($tn > $to)
session_start();
session_register('$sess_visitor');
session_register('$sess_last_visit');
}
?>
</PRE>