Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.