Skip to content

Commit

Permalink
Session DatabaseHandler was not reading back values correctly. Fixes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
lonnieezell committed Apr 20, 2018
1 parent e7f3ab0 commit 74e95d3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions system/Session/Handlers/DatabaseHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions system/Session/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ public function __construct(\SessionHandlerInterface $driver, $config)
$this->cookieDomain = $config->cookieDomain;
$this->cookiePath = $config->cookiePath;
$this->cookieSecure = $config->cookieSecure;

helper('array');
}

//--------------------------------------------------------------------
Expand Down Expand Up @@ -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))
{
Expand Down

0 comments on commit 74e95d3

Please sign in to comment.