I have code with the following segment in it. This block is actually a debug block used to check before making the script live.
if ($_COOKIE['visits'] = '' )
{
$dbgmsg="No cookie found";
$visits=1;
setcookie('visits',$visits,time() + (86400*30)); // 86400 = 1 day 900=15mins
}
else
{
$visits=$_COOKIE['visits'];
//$dbgmsg="Cookie found. Value is".$_COOKIE['visits'];
$dbgmsg='<p>Cookie found. Value is'.$_COOKIE["visits"].'</p>';
$visits++;
setcookie('visits',$visits,time() + (86400*30));
}
When the script runs, the output is: Cookie found. Value is
Meaning the value of the cookie is not displayed. Checking the cookie value in Chrome shows that the cookie 'visits' exists, with a value 1. But the code seems to be going into the else block. But the value retrieved is null?
I wish to increment the value of the cookie depending on visits.