Session DatabaseHandler was not reading back values correctly. Fixes #958

This commit is contained in:
Lonnie Ezell 2018-04-19 23:55:05 -05:00
parent e7f3ab0841
commit 74e95d35ed
No known key found for this signature in database
GPG Key ID: 8EB408F8D82F5002
2 changed files with 8 additions and 4 deletions

View File

@ -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 @@ class DatabaseHandler extends BaseHandler implements \SessionHandlerInterface
$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

View File

@ -166,6 +166,8 @@ class Session implements SessionInterface
$this->cookieDomain = $config->cookieDomain;
$this->cookiePath = $config->cookiePath;
$this->cookieSecure = $config->cookieSecure;
helper('array');
}
//--------------------------------------------------------------------
@ -463,9 +465,9 @@ class Session implements SessionInterface
*/
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))
{