Skip to content

Commit

Permalink
Return empty string on non-existent session read()
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeBiellik committed Dec 17, 2015
1 parent 268dfa3 commit 1b0b4fc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/Network/Session/CacheSession.php
Expand Up @@ -78,11 +78,17 @@ public function close()
* Method used to read from a cache session.
*
* @param string $id The key of the value to read
* @return mixed The value of the key or false if it does not exist
* @return string The value of the key or empty if it does not exist
*/
public function read($id)
{
return Cache::read($id, $this->_options['config']);
$value = Cache::read($id, $this->_options['config']);

if (empty($value)) {
return '';
}

return $value;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Network/Session/DatabaseSession.php
Expand Up @@ -89,7 +89,7 @@ public function close()
* Method used to read from a database session.
*
* @param int|string $id The key of the value to read
* @return mixed The value of the key or false if it does not exist
* @return string The value of the key or empty if it does not exist
*/
public function read($id)
{
Expand All @@ -101,7 +101,7 @@ public function read($id)
->first();

if (empty($result)) {
return false;
return '';
}

if (is_string($result['data'])) {
Expand Down

0 comments on commit 1b0b4fc

Please sign in to comment.