duanjieyi6582 2017-10-17 07:56
浏览 163
已采纳

Codeigniter设置cookie但它无法获取它

I am using Codeigniter 3.1.6 and I am using the provided library to set a cookie.

$this->load->helper(array('cookie', 'url'));
    set_cookie('cookie_policy', true, '2592000', 'host', '/', '', TRUE);

The cookie is set correctly and I can see that in the browser. I can retrieve it but after I close my browser the cookie cant be get anymore. However, in the browser I can see it. I tried to get it with just plain PHP script but still was not not working.

Anyone have this problem before?

Thanks in advance.

  • 写回答

2条回答 默认 最新

  • donglun4521 2017-10-17 08:04
    关注

    Try with this

    set_cookie('cookie_policy', true, 2592000, '', '', '', TRUE);
    

    If no luck add ob_flush() and ob_start() to above method

    Sometimes the value filed expecting int or string. Not sure. Just a mad idea

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?