Steven
Steven

Reputation: 25274

Cookies can not be retrieved using PHP

This is the command with which I set cookies:

setcookie('username', $username, strtotime('+1 months'), '/', '.localdomain.com/jp/');

This is the statement with which cookie is read:

$user=$_COOKIE['username'];

Why can I not read cookies on another page?

Upvotes: 0

Views: 105

Answers (1)

Greg
Greg

Reputation: 321578

Your setcookie() call is wrong - you can't have a path in the domain part - it should be:

setcookie('username', $username, strtotime('+1 months'), '/jp/', '.localdomain.com');

Upvotes: 2

Related Questions