更新时间:2023-11-19 17:48:22
问题可能出在您的内部域变量
BASE_URL不是CI常量的一部分,可能不包含您期望的内容或cookie初始化所需的内容。
The problem is probably within your domain variable BASE_URL, which isn't a part of CI constants, probably doesn't contain what you expect or what a cookie initialization requires.
尝试做像这样:
//Setup a guid
$guid = uniqid();
//Setup a random cookie and point it to db user
$cookie = array(
'name' => 'TheCookieName',
'value' => $guid,
'expire' => 86500, // have a high cookie time till you make sure you actually set the cookie
'domain' => '.example.org', // the first . to make sure subdomains isn't a problem
'path' => '/',
'secure' => TRUE
);
set_cookie($cookie);
请记住,在发出新请求之前,cookie永远不可用。
重定向到另一个Cookie设置中指定的域上的页面,然后再次检查Cookie。
Remember that cookies will never be available until a new request have been made.
Redirect to another page on the domain specified in the cookie setup and check for the cookie again.