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 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺