开发者

session expires and so does my cookie

I have set cookie and set it to expire after sufficient seconds. Still as soon as my session expires the cookie also expires. This is my code :-

   if(isset($_POST['KeepMesignedIn开发者_JAVA技巧'])) {
                    $this->load->helper('cookie');
                    $cookie = array(
                            'name'   => 'info',
                            'value'  =>  $user->Username . '||' . $user->Password,
                            'expire' => time()+3600*24*30
                    );

                    set_cookie($cookie);
                }

Can anybody identify the problem?


According to the CodeIgniter documentation, set_cookie expects expires to be the delta seconds that are added to the current time:

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.


check is this part of code executed in your app or not. You need to debug.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜