diff options
author | diosmosis <diosmosis@users.noreply.github.com> | 2019-08-06 23:35:03 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-06 23:35:03 +0300 |
commit | be4540fd4c15118bf773683d6c7848b22af903a1 (patch) | |
tree | 17b30a6bab489c1b3ddb0a48842ae081ac040ff0 | |
parent | e34f66be743325e1cb9264ce0df301d40bef6d0c (diff) |
In case global config is not working, default idle timeout so user can still login. (#14736)
-rw-r--r-- | core/Session/SessionFingerprint.php | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/core/Session/SessionFingerprint.php b/core/Session/SessionFingerprint.php index 4955247d08..df8a519e5e 100644 --- a/core/Session/SessionFingerprint.php +++ b/core/Session/SessionFingerprint.php @@ -36,6 +36,9 @@ use Piwik\Date; */ class SessionFingerprint { + // used in case the global.ini.php becomes corrupt or doesn't update properly + const DEFAULT_IDLE_TIMEOUT = 3600; + const USER_NAME_SESSION_VAR_NAME = 'user.name'; const SESSION_INFO_SESSION_VAR_NAME = 'session.info'; const SESSION_INFO_TWO_FACTOR_AUTH_VERIFIED = 'twofactorauth.verified'; @@ -138,8 +141,17 @@ class SessionFingerprint { $time = $time ?: Date::now()->getTimestampUTC(); - $nonRememberedSessionExpireTime = Config::getInstance()->General['login_session_not_remembered_idle_timeout']; - $sessionCookieLifetime = Config::getInstance()->General['login_cookie_expire']; + $general = Config::getInstance()->General; + + if (!isset($general['login_session_not_remembered_idle_timeout']) + || (int) $general['login_session_not_remembered_idle_timeout'] <= 0 + ) { + $nonRememberedSessionExpireTime = self::DEFAULT_IDLE_TIMEOUT; + } else { + $nonRememberedSessionExpireTime = (int) $general['login_session_not_remembered_idle_timeout']; + } + + $sessionCookieLifetime = $general['login_cookie_expire']; if ($this->isRemembered()) { $expireDuration = $sessionCookieLifetime; |