Luca Sara Czudar
Luca Sara Czudar

Reputation: 73

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();
    Yii::app()->user->login($this->_identity,$duration);

(the 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.

Upvotes: 0

Views: 584

Answers (1)

Luca Sara Czudar
Luca Sara Czudar

Reputation: 73

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.

Upvotes: 1

Related Questions