user2467899
user2467899

Reputation: 575

Create a cookie with PHP

I don't understand where is my mistake:

Page a.php:

setcookie("user",$username,time()+300);

Page b.php:

echo $_COOKIE['user']; or echo $_COOKIE["user"];

The result is that echo doesn't print nothing!

Thank you very much for the help!

Upvotes: 1

Views: 83

Answers (1)

Zevi Sternlicht
Zevi Sternlicht

Reputation: 5399

Either $username has no value or you have white-space before you are setting the cookie. Cookies must be sent with the header information before any HTML is sent at all so make sure the

Upvotes: 1

Related Questions