if($_GET['test'] == 1) { setCookie('user_hash', 123, time() + 86400, '/'); } echo $_COOKIE['user_hash']; 

This is certainly strange, but this cookie lasts for 5-6 minutes and then is removed. How can this be?

  • Browser maybe? - stck

1 answer 1

Try this, do not specify this parameter at the end "/"

  $val="123"; if (setcookie ("user_hash", $val,time()+86400);) echo "<h3>Печенюшки испеклись!</h3>"; else echo "<h3>Печенюшки, не испеклись :(!</h3>"; 

Well, if a cookie has a 24-hour life, then until you clear the cache of cookies or go through the day, you will have the cookie.

  • @Shrek, I stayed like this, it is still reset ... It lasts only 5 minutes. - ModaL
  • Yes, there can be no such, it means problems in the browser. What browser do you use? open the page settings in the moss door and see the cookies on it. updated answer. - Artem