definitely not a dev definitely not a dev - 7 months ago 35
PHP Question

Yii 1.1x logs out the user before session timeout

I'm using Yii 1.1.13 and despite the session timeout is set to 1 day (

session.gc_maxlifetime = 86400
in php.ini) Yii logs out the user after ~24 mins. It doesn't even redirect to the login page, only when the user would navigate to another page.

I set these in the login function:

$duration = Yii::app()->getSession()->getTimeout();

call gives back the right time, that is 86400)

I also set the cookie lifetime to this value:

Yii::app()->request->cookies['PHPSESSID']->expire = Yii::app()->getSession()->getTimeout();

but the bug still appears.

Thank you in advance for your helping answers.


I needed to set this in my main.php:

'session' => array(
    'timeout' => 86400,
    'cookieParams' => array(
            'lifetime' => 86400,

It keeps alive both the session and the cookie even if they are somehow given a lower value.