Jump to content

I'm going crazy with COOKIES!


KohPhiPhi

Recommended Posts

Hello everyone,

 

I am going crazy with a small PHP code that I've used dozens of times before but, for whatever reason, it's not working out today. I've checked the code and it seems OK to me, but for whatever reason my code cannot find a cookie on my browser (a cookie I KNOW it exists!).

 

Ok, firstly I insert a cookie on the browser with the following code;

 

$month = time()+60*60*24*30*12*10;
$value = time();
setcookie("oldvisitor",$value, $month);

 

And then I am trying to display a custom message on another page of my site using the following code:

 

if(isset($_COOKIE['oldvisitor']))
{ 
$message = "Welcome back!";
} 
else
{ 
$message = "Welcome to our site!";
}

echo $message;

 

But every time I visit that page I get the "Welcome to our site!" message, even though I have checked on my cookie list (Firefox 3.5) that the cookie "oldvisitor" is indeed there.

 

Why is my page not recognizing that cookie? I've used this same code forever and this is the first time it's not working for me :(

 

Any help is greatly appreciated!

Link to comment
https://forums.phpfreaks.com/topic/197911-im-going-crazy-with-cookies/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.