我需要保存一个Cookie,我尝试使用setcookie
函数执行此操作,我做了:
$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
);
在浏览器中没有保存cookie,为什么?
答案 0 :(得分:1)
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 u r not using ssl
true
);
您的部分设置有误。我已经纠正了你能试试吗?