if(isset($_COOKIE['fb_userId'])){
setcookie('fb_userId', $userId);
}
I put this within one of my controller, the cookie named userId should be inserted after the call right? but I checked the resources tab of my chrome, I don't see anything..
I also tried the helper method like this
$this->input->set_cookie($cookie_arr);
In your code above, it will only set the cookie if the same cookie name (fb_userId) already exists.
Try use the following code:
if(!isset($_COOKIE['fb_userId'])){
setcookie('fb_userId', $userId);
}
I've add the ! before your isset()
if you want to set cookie in Codeigniter than you can use that code
$this->load->helper('cookie');
$cookie = array(
'name' => 'testcookie',
'value' => 'test value',
'expire' => '86500'
);
$this->input->set_cookie($cookie);
echo $_COOKIE['testcookie'];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.