douke7274 2013-08-28 02:01
浏览 40

Codeigniter,xampp cookies没有设置

I'm using the codeigniter with xampp on a windows 7 PC.

I'm trying to use codeigniter's built in cookies, but I can't seem to get my cookies to set/stay. I know that the cookie code is going off, it's just not actually saving.

Here's the cookie code:

$this->input->set_cookie('userID', $userID, time()+259200, 'http://localhost', '/');

After running this and on every page, I've included print_r($_COOKIE); to see any/all cookies that are being set, but nothing shows up.

Is there something I've missed?

  • 写回答

2条回答 默认 最新

  • dounue1965 2013-08-28 05:21
    关注

    According to the docs:

    The expiration is set in seconds, which will be added to the current time. Do not include the time, but rather only the number of seconds from now that you wish the cookie to be valid. If the expiration is set to zero the cookie will only last as long as the browser is open.

    So your code should be like this:

    $this->input->set_cookie('userID', $userID, 259200);
    

    Also i recommend you to set domain name and cookie path in the config file.

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器