Yii用户在15-30分钟后注销,尽管会话超时设置为至少1天 [英] Yii users being logged out after 15-30 minutes despite session timeouts being set to at least 1 day

查看:567
本文介绍了Yii用户在15-30分钟后注销,尽管会话超时设置为至少1天的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在下面包含了我们的Yii配置文件的相关部分:

I've included the relevent parts of our Yii config file below:

return array(
...
    'components'=>array(
        'session' => array(
            'timeout' => 86400,
        ),
        'user'=>array(
            'allowAutoLogin' => true,
            'autoRenewCookie' => true,
            'authTimeout' => 31557600,
        ),
    ...
    ),
...
);

我也进入php.ini并设置 session.gc_maxlifetime = 86400 ,但这仍然没有解决问题。

I have also been into php.ini and set session.gc_maxlifetime = 86400 but this still hasn't fixed the problem.

目前,我绝对失去了什么可能会导致它超时和在大约15-30分钟不活动后,将用户记录下来。理想情况下,用户应该保持登录状态至少一天不活动(并且关闭浏览器窗口,浏览器偏好设置允许)。

Currently, Im absolutely at a loss as to what else could be causing it to timeout and log the user out after roughly 15-30 minutes of inactivity. Ideally users should remain logged in for at least a day of inactivity (and beyond closing the browser window, browser preferences allowing).

我已经拖网谷歌,Yii和堆栈溢出,只是找不到任何东西,我忽略...但显然我俯瞰的东西。如果任何人可以帮助我,我将非常感谢。

I've trawled google, Yii and stack overflow and just can't find anything that I'm overlooking... but clearly I am overlooking something. If anyone can help me out I'd be very grateful.

我们使用的典型代码示例在用户中被请求并包括如下:

A sample of typical code that we are using to log in the users was requested and is included below:

$identity = new UserIdentity('facebook', $id, $user->name, $user->email);
$loggedIn = Yii::app()->user->login($identity);
$this->subscriptionChecker->updateCurrentUserSubscribed();

这是非常典型的任何时候 Yii :: app > user-> login()

This is pretty typical of any time that Yii::app()->user->login() is called

(在清除所有Cookie并仅登录之后):

From Chrome, here are the cookies I have for the site and their expiries (after clearing all cookies and just logging in):

PHPSESSID expires When the browsing session ends

// I'm informed these are set by google analytics  
__utma created Friday, 12 October 2012 14:05:31 expires Sunday, 12 October 2014 14:05:31

__utmb created Friday 12 October 2012 14:05:31 expires Friday 12 October 2012 14:35:31,

__utmc created Friday, 12 October 2012 14:05:31 expires When the browsing session ends

__utmz created Friday 12 October 2012 14:05:31 expires Saturday 13 April 2013 02:05:31  
// end google analytics


推荐答案

http://www.yiiframework.com/doc/api/1.1/CWebUser#login-detail

谢谢除非你设置 Yii :: app() - > user-> login()的第二个参数,它会帮助来自Arfeen的指向正确方向Yii不会使用持久性cookie,因为第二个参数默认为0.这个默认的0值覆盖你可能已经设置的超时任何其他事情。

Thanks to help from Arfeen who pointed me in the right direction, unless you set the second parameter of Yii::app()->user->login() it turns out that Yii will not use a persistent cookie, as the second parameter defaults to 0. This default 0-value overrides anything else you might have set to do with timeouts.

这篇关于Yii用户在15-30分钟后注销,尽管会话超时设置为至少1天的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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