KohPhiPhi Posted April 7, 2010 Share Posted April 7, 2010 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! Quote Link to comment https://forums.phpfreaks.com/topic/197911-im-going-crazy-with-cookies/ Share on other sites More sharing options...
premiso Posted April 7, 2010 Share Posted April 7, 2010 Try defining the path and domain (See setcookie for usage examples). And see if giving it more proper parameters will help it work. Quote Link to comment https://forums.phpfreaks.com/topic/197911-im-going-crazy-with-cookies/#findComment-1038615 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.