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条)

报告相同问题?

悬赏问题

  • ¥15 outlook无法配置成功
  • ¥15 Pwm双极模式H桥驱动控制电机
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换