E
E
eldar_web2015-03-18 14:35:18
Yii
eldar_web, 2015-03-18 14:35:18

How to increase session time in yii?

Using the code Yii::app()->session->add($user->role,'1') you can add a session.
But how can you change the session time?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
yiiworld, 2017-11-21
@yiiworld

For Yii2, you need to add a timeout value with the specified number of seconds to the configuration (/config/web.php for the base application).
For example for 10 years:

$config = [
...
  'components' => [
        ...
    'session'=>[
      		'timeout'=>10*365*24*60*60,
    ],
  ...
  ],
...
];

A
Alexander N++, 2015-03-18
@sanchezzzhak

php.net/manual/ru/session.configuration.php#ini.se...
The session lifetime is changed in the php.ini settings, through htaccess if you use Apache or through php.
Open index.php

ini_set('session.gc_maxlifetime', 120960);
ini_set('session.cookie_lifetime', 120960);
ini_set('session.save_path', __DIR__.'/../sessions/');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question