Page 1 of 1

showing cookie not working

Posted: Tue Jun 09, 2009 4:25 pm
by tomsace
I have managed to get the code to save the cookie to my computer using the following code:

Code: Select all

<?php setcookie("excludeAnalytics", excludeAnalytics, time()+31536000, "/", ".zippygame.com", 1); ?>
Now I cant use the cookie, when I try to echo it or use it, it still doesn't work?? I have tried using:

Code: Select all

<?php
if(isset($_COOKIE['excludeAnalytics']))
  { echo "Showing"; }
else
  { echo "Not Showing"; } ?>
This is so that I can show some text if the cookie exists, or show something else if the cookie doesn't exist.

Re: showing cookie not working

Posted: Tue Jun 09, 2009 5:42 pm
by requinix
You passed 1 as the 'secure' argument. That means the cookie will only be set over a secure (HTTPS) connection. Was that intentional?

Have you verified that the cookie actually exists on your computer?

Re: showing cookie not working

Posted: Tue Jun 09, 2009 5:52 pm
by tomsace
Oh right, yes I was sure it existed on the computer.

I removed the '1' and it works perfectly. Thanks alot.