diff --git a/system/Session/Handlers/DatabaseHandler.php b/system/Session/Handlers/DatabaseHandler.php index ae67a81b31b0..e22553ff8d6a 100644 --- a/system/Session/Handlers/DatabaseHandler.php +++ b/system/Session/Handlers/DatabaseHandler.php @@ -35,9 +35,9 @@ * @since Version 3.0.0 * @filesource */ +use Config\Database; use CodeIgniter\Config\BaseConfig; use CodeIgniter\Database\BaseConnection; -use Config\Database; /** * Session handler using current Database for storage @@ -169,7 +169,9 @@ public function read($sessionID) $builder = $builder->where('ip_address', $_SERVER['REMOTE_ADDR']); } - if ($result = $builder->get()->getRow() === null) + $result = $builder->get()->getRow(); + + if ($result === null) { // PHP7 will reuse the same SessionHandler object after // ID regeneration, so we need to explicitly set this to diff --git a/system/Session/Session.php b/system/Session/Session.php index f1e86add74f8..99779f011a81 100644 --- a/system/Session/Session.php +++ b/system/Session/Session.php @@ -166,6 +166,8 @@ public function __construct(\SessionHandlerInterface $driver, $config) $this->cookieDomain = $config->cookieDomain; $this->cookiePath = $config->cookiePath; $this->cookieSecure = $config->cookieSecure; + + helper('array'); } //-------------------------------------------------------------------- @@ -463,9 +465,9 @@ public function set($data, $value = null) */ public function get(string $key = null) { - if (isset($key)) + if ($value = dot_array_search($key, $_SESSION)) { - return $_SESSION[$key] ?? null; + return $value; } elseif (empty($_SESSION)) {