Cookie issues (Codeigniter)
I think I must be having a brain freeze because for the life of me, I can't seem to understand this. I am using CodeIgniter to set cookie for a Facebook status. When a user first lands on a fan page and isn't a fan, I set the cookie to "NOT LIKED YET". Then, when the user likes the page, the page is reloaded and the cookie is checked for a value. If the cookie exists and the value is "NOT LIKED YET", I set the cookie to "ALREADY LIKED".
Somehow, when I trace the cookie in Firebug, it always says "NOT LIKED YET" although the headers for the page clearly shows the cookie value has changed. Any ideas what I am doing incorrectly?
if ($fan_page_liked == '')
开发者_Python百科{
$this->_set_cookie_for_conversion('NOT LIKED YET');
$data['before_like'] = $this->config->item('before_like_image');
} else if($fan_page_liked == 1)
{
$after_like_cookie = get_cookie($facebook_cookie);
if ($after_like_cookie == 'NOT LIKED YET')
{
$this->_set_cookie_for_conversion('ALREADY LIKED');
}
}
private function _set_cookie_for_conversion($value)
{
$this->load->helper('cookie');
$facebook_cookie = $this->config->item('facebook_like_cookie');
$cookie = array(
'name' => $facebook_cookie,
'value' => $value,
'expire' => '86500'
);
set_cookie($cookie);
}
Well, I closed my browser, went to bed and then when I reopened the project the next day, the cookies worked as coded. Perhaps Firecookie went a little crazy since I had the same browser window was open the entire day?
Thanks for everyone's help.
精彩评论