mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Add option to make _validAgentAndTime
3.x compatible
This commit is contained in:
parent
6343219d9b
commit
bc1678cf2a
1 changed files with 17 additions and 0 deletions
|
@ -134,6 +134,13 @@ class CakeSession {
|
|||
*/
|
||||
protected static $_cookieName = null;
|
||||
|
||||
/**
|
||||
* Whether or not to make `_validAgentAndTime` 3.x compatible.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected static $_useForwardsCompatibleTimeout = false;
|
||||
|
||||
/**
|
||||
* Whether this session is running under a CLI environment
|
||||
*
|
||||
|
@ -360,6 +367,9 @@ class CakeSession {
|
|||
protected static function _validAgentAndTime() {
|
||||
$userAgent = static::read('Config.userAgent');
|
||||
$time = static::read('Config.time');
|
||||
if (static::$_useForwardsCompatibleTimeout) {
|
||||
$time += (Configure::read('Session.timeout') * 60);
|
||||
}
|
||||
$validAgent = (
|
||||
Configure::read('Session.checkAgent') === false ||
|
||||
isset($userAgent) && static::$_userAgent === $userAgent
|
||||
|
@ -527,6 +537,10 @@ class CakeSession {
|
|||
if (isset($sessionConfig['timeout']) && !isset($sessionConfig['cookieTimeout'])) {
|
||||
$sessionConfig['cookieTimeout'] = $sessionConfig['timeout'];
|
||||
}
|
||||
if (isset($sessionConfig['use_forwards_compatible_timeout']) && $sessionConfig['use_forwards_compatible_timeout']) {
|
||||
static::$_useForwardsCompatibleTimeout = true;
|
||||
}
|
||||
|
||||
if (!isset($sessionConfig['ini']['session.cookie_lifetime'])) {
|
||||
$sessionConfig['ini']['session.cookie_lifetime'] = $sessionConfig['cookieTimeout'] * 60;
|
||||
}
|
||||
|
@ -580,6 +594,9 @@ class CakeSession {
|
|||
}
|
||||
Configure::write('Session', $sessionConfig);
|
||||
static::$sessionTime = static::$time + ($sessionConfig['timeout'] * 60);
|
||||
if (static::$_useForwardsCompatibleTimeout) {
|
||||
static::$sessionTime = static::$time;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue