Skip to content

Commit 1a644a2

Browse files
committed
Merge pull request #70 from dvdkrgr/master
Added the possibility to set cookie lifetime by config file
2 parents db24d9a + ce7560b commit 1a644a2

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

components/UserConfig.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ class UserConfig extends User
2020
* @inheritdoc
2121
*/
2222
public $enableAutoLogin = true;
23-
23+
24+
/**
25+
* @inheritdoc
26+
*/
27+
public $cookieLifetime = 2592000;
28+
2429
/**
2530
* @inheritdoc
2631
*/
@@ -54,4 +59,4 @@ protected function afterLogin($identity, $cookieBased, $duration)
5459
parent::afterLogin($identity, $cookieBased, $duration);
5560
}
5661

57-
}
62+
}

models/forms/LoginForm.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function login()
8989
{
9090
if ( $this->validate() )
9191
{
92-
return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0);
92+
return Yii::$app->user->login($this->getUser(), $this->rememberMe ? Yii::$app->user->cookieLifetime : 0);
9393
}
9494
else
9595
{

0 commit comments

Comments
 (0)