codeigniter cookie到期问题 [英] codeigniter cookie expiry problem

查看:106
本文介绍了codeigniter cookie到期问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到cookie问题,我的cookie上的到期日期总是设置为会话结束,这不是我想要的。我做了一番咯咯的,它建议它设置过期时间()+ 60 * 60 * 24 * 30我做了。

I'm having a cookie issue, the expiry date on my cookie is always being set to At End Of Session which isn't what I want. I did a bit of goggling and it suggested it set the expire to time()+60*60*24*30 which I've done.

 //Create basket cookie
            $cookie = array(
                'name'   => 'basket_id',
                'value'  => $basket_id,
                'expire' => time()+60*60*24*30,
                'domain' => 'domain',
                'path'   => '/',
                'prefix' => '',
            );
            set_cookie($cookie);

我想知道是否可能是一个Codeignter设置,但我的ci_session cookie有正常的到期日期。 Thu,09 Jun 2011 10:39:02 GMT

I did wonder if it could be down to a Codeignter setting but my ci_session cookie has a normal expiry date. Thu, 09 Jun 2011 10:39:02 GMT

这是我在查看Cookie时得到的:

This is what I get when I view the cookie:

 Name   basket_id
 Value  28
 Host   .host
 Path   /
 Secure No
 Expires    At End Of Session

这是我传给cookie的数组的例子。

And here is an example of the array I'm passing to the cookie.

Array ( [name] => basket_id [value] => 30 [expire] => 1310202067 [domain] => host [path] => / [prefix] => ) 


推荐答案

可以尝试调整会话到期时间 config.php CI会话最初保存在cookie中:

You can try to adjust session expiration time in config.php CI session initially is saved in cookies:

/** Session Variables
 ---------------------------------------
| 'session_expiration'  = the number of SECONDS you want the session to last.
|  by default sessions last 7200 seconds (two hours).  Set to zero for no expiration.
|
*/

$config['sess_expiration']      = 7200;

这篇关于codeigniter cookie到期问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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