• Steam recently changed the default privacy settings for all users. This may impact tracking. Ensure your profile has the correct settings by following the guide on our forums.

Cookie problems

Status
Not open for further replies.

Darkchild

The Doctor
I'm trying to set cookies with the "setcookie" function in PHP...

example of the code :

PHP:
setcookie("data1", $data1, time()+3600);

the cookie is always empty!!
(yes, I set the cookies before the <html> tag... )

here's the "print_r" of the cookie:
Code:
Array ( )

though, if I reload the PHP, and set them for the second time, it works.

I don't get it (the code does arrive to the part where it sets the cookies, I checked)
 
$_COOKIE is populated by what stored cookies the user sends the server.
Since on first load the user has no cookie there is nothing sent to the server so $_COOKIE is empty, even after you set a cookie.
The second time the page is loaded the user has a cookie and it will be sent to the server so $_COOKIE will contain some information.
 
Status
Not open for further replies.
Back
Top