Joesavage Posted May 26, 2009 Share Posted May 26, 2009 I am trying to use a cookie to tell when someone has already been to my website. Right now the problem is that if the cookie gets set on one page, it does not get read by other pages. $Affcookie = 0; $Affcookie = $_COOKIE["track"]; if ($Affcookie == 0) { $Cookvar = 1; $Expire = time() + 60*60*24*60; setcookie("track", 1, $Expire); } if ($Cookvar == 1;) { echo 'blah'; } Right now if I go to a page on my domain it first echoes 'blah' and then if i refresh then it doesnt echo, which is correct. But if I go to any other page on my domain then once again 'blah' is echoed. All pages have this is same piece of code on them. So they all check to see if the cookie[track] = 1. Quote Link to comment https://forums.phpfreaks.com/topic/159637-php-cookies-not-working-throughout-domain/ Share on other sites More sharing options...
Masna Posted May 26, 2009 Share Posted May 26, 2009 Try this: $Affcookie = 0; $Affcookie = $_COOKIE["track"]; if ($Affcookie == 0) { $Cookvar = 1; $Expire = time() + 60*60*24*60; setcookie("track", 1, $Expire, "/"); } if ($Cookvar == 1;) { echo 'blah'; } Quote Link to comment https://forums.phpfreaks.com/topic/159637-php-cookies-not-working-throughout-domain/#findComment-842003 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.