Codeigniter中的会话超时Cookie过期 [英] Cookie expires on session out in Codeigniter

查看:264
本文介绍了Codeigniter中的会话超时Cookie过期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码在我的codeigniter应用程序中设置cookie。工作正常..但cookie会在会话结束时过期。请帮助

  $ cookie = array(
'name '=>'tvcUsername',
'value'=> $ email,
'expire'=> time()+ 86500,
'domain'=> // localhost / tvc',
'path'=>'/',
'prefix'=>'',

);

$ this-> input-> set_cookie($ cookie);

提前感谢

解决方案

我可以想到的两件事:



a)localhost不是有效的域,所以不会为所有浏览器保存cookie。为my.dev.server或localhost.dev创建一个HOST并指向127.0.0.1(您可能还需要配置apache来响应该名称 - 但首先尝试更改HOSTS文件) / p>

此外,您的域包括一个方案和一个路径 - 可能会导致问题?设置为localhost.dev(删除http://和/ tvc部分 - 一旦你已经离开localhost。


I am setting a cookie in my codeigniter application using the following code. Working fine .. but cookie get expires on session out.. Please help

$cookie = array(
        'name'   => 'tvcUsername',
        'value'  => $email,
        'expire' => time()+86500,
        'domain' => 'http://localhost/tvc',
        'path'   => '/',
        'prefix' => '',

    );

    $this->input->set_cookie($cookie);

Thanks in advance

解决方案

Two things I can think of:

a) localhost is not a valid domain, so cookies won't be saved for all browsers. Create yourself a HOST for "my.dev.server" or "localhost.dev" and point to 127.0.0.1 (you may also need to configure apache to respond to that name - but try it first just changing the HOSTS file first)

b) In addition, your "domain" includes a scheme and a path - that might be causing problems? Set to "localhost.dev" (drop the "http://" and the "/tvc" parts - once you've moved away from localhost.

这篇关于Codeigniter中的会话超时Cookie过期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆