diff --git a/deptrac.yaml b/deptrac.yaml index 8d43af6117ae..ddcaa43d9dba 100644 --- a/deptrac.yaml +++ b/deptrac.yaml @@ -201,6 +201,7 @@ parameters: - Cookie - HTTP - Database + - I18n Throttle: - Cache Validation: diff --git a/system/Session/Session.php b/system/Session/Session.php index fa44b8267e7b..d45a7b75fc74 100644 --- a/system/Session/Session.php +++ b/system/Session/Session.php @@ -13,6 +13,7 @@ use CodeIgniter\Cookie\Cookie; use CodeIgniter\HTTP\Response; +use CodeIgniter\I18n\Time; use Config\App; use Config\Cookie as CookieConfig; use Config\Services; @@ -182,7 +183,7 @@ public function __construct(SessionHandlerInterface $driver, App $config) $cookie = config('Cookie'); $this->cookie = (new Cookie($this->sessionCookieName, '', [ - 'expires' => $this->sessionExpiration === 0 ? 0 : time() + $this->sessionExpiration, + 'expires' => $this->sessionExpiration === 0 ? 0 : Time::now()->getTimestamp() + $this->sessionExpiration, 'path' => $cookie->path ?? $config->cookiePath, 'domain' => $cookie->domain ?? $config->cookieDomain, 'secure' => $cookie->secure ?? $config->cookieSecure, @@ -238,8 +239,8 @@ public function start() && ($regenerateTime = $this->sessionTimeToUpdate) > 0 ) { if (! isset($_SESSION['__ci_last_regenerate'])) { - $_SESSION['__ci_last_regenerate'] = time(); - } elseif ($_SESSION['__ci_last_regenerate'] < (time() - $regenerateTime)) { + $_SESSION['__ci_last_regenerate'] = Time::now()->getTimestamp(); + } elseif ($_SESSION['__ci_last_regenerate'] < (Time::now()->getTimestamp() - $regenerateTime)) { $this->regenerate((bool) $this->sessionRegenerateDestroy); } } @@ -379,7 +380,7 @@ protected function initVars() return; } - $currentTime = time(); + $currentTime = Time::now()->getTimestamp(); foreach ($_SESSION['__ci_vars'] as $key => &$value) { if ($value === 'new') { @@ -403,7 +404,7 @@ protected function initVars() */ public function regenerate(bool $destroy = false) { - $_SESSION['__ci_last_regenerate'] = time(); + $_SESSION['__ci_last_regenerate'] = Time::now()->getTimestamp(); session_regenerate_id($destroy); $this->removeOldSessionCookie(); @@ -804,7 +805,7 @@ public function removeTempdata(string $key) */ public function markAsTempdata($key, int $ttl = 300): bool { - $ttl += time(); + $ttl += Time::now()->getTimestamp(); if (is_array($key)) { $temp = []; @@ -815,9 +816,9 @@ public function markAsTempdata($key, int $ttl = 300): bool $k = $v; $v = $ttl; } elseif (is_string($v)) { - $v = time() + $ttl; + $v = Time::now()->getTimestamp() + $ttl; } else { - $v += time(); + $v += Time::now()->getTimestamp(); } if (! array_key_exists($k, $_SESSION)) { @@ -919,7 +920,7 @@ protected function startSession() */ protected function setCookie() { - $expiration = $this->sessionExpiration === 0 ? 0 : time() + $this->sessionExpiration; + $expiration = $this->sessionExpiration === 0 ? 0 : Time::now()->getTimestamp() + $this->sessionExpiration; $this->cookie = $this->cookie->withValue(session_id())->withExpires($expiration); /** @var Response $response */