I need to save a cookie, I’m trying to do this with setcookie function, I did:
$selector = base64_encode(random_bytes(9));
$token = random_bytes(33);
$expires = time() + 864000;
setcookie(
'remember',
$selector . ":" . base64_encode($token),
$expires,
'/',
'http://webserver/myapp/',
true,
true
);
in the browser there is no cookie saved, why?
Advertisement
Answer
setcookie(
'remember',
$selector . ":" . base64_encode($token),
$expires,
'/myapp/', // Cookie at this folder path only
'webserver', // This should be set to the domain the cookie is valid on
False, // Set to false if you are not using ssl
true
);
Some of your settings are wrong. I’ve corrected can you try?