I’m new PHP guy and I’m using PHP cookie and I’m facing a problem that the cookie can not be set correctly.
Here is the statement of Set Cookie
setcookie(‘cookieusername’, $username, 100000);
and the statement of Get Cookie
$cookieusername = $_COOKIE[“cookieusername”];
The problem is, the value of $_COOKIE["cookieusername"]; is not defined.
I don’t know what the problem is. I have tired to set the cookie path to ‘/’ but which was still not work.
Instead of:
you have to do:
The reason is that the third parameter is the expiry time (as a Unix timestamp (number of seconds since the epoch)), not the time until expiry. And here’s the link of manual.