mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
Session DatabaseHandler was not reading back values correctly. Fixes #958
This commit is contained in:
parent
e7f3ab0841
commit
74e95d35ed
@ -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
|
||||
|
@ -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))
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user