Forum Moderators: coopster
I'm trying to create a special cookie.
If the user doesnt have this cookie, a cookie will be set equal to 1.
If the user does have this cookie set, the value will be read (and used further down in the script), and then that cookie will be overwritten with it's current value +1.
I've written the following script, but it's not working, and I think it might have something to do with the fact that 1 is trying to be added to a string, maybe?
if(isset($_COOKIE["count"])){$count==$_COOKIE["count"]+1;setcookie("count",$count,time()+604800);}else{setcookie("count","1",time()+604800);$count="1";}
echo ($count);
Thanks for any help.
you are using == which, as I understand it, is a comparison operator (i.e you are comparing two values to see if they are equal). If I understood your script correctly, you want to assign new value to $count, in which case you should use =. If this presumtion is correct try something like this:
$count = ($_COOKIE["count"]+1);
HTH