diff --git a/src/Protocols/Http/Session/FileSessionHandler.php b/src/Protocols/Http/Session/FileSessionHandler.php index aea6d06e7..219171c0d 100644 --- a/src/Protocols/Http/Session/FileSessionHandler.php +++ b/src/Protocols/Http/Session/FileSessionHandler.php @@ -88,19 +88,19 @@ public function open(string $savePath, string $name): bool /** * {@inheritdoc} */ - public function read(string $sessionId): string + public function read(string $sessionId): string|false { $sessionFile = static::sessionFile($sessionId); clearstatcache(); if (is_file($sessionFile)) { if (time() - filemtime($sessionFile) > Session::$lifetime) { unlink($sessionFile); - return ''; + return false; } $data = file_get_contents($sessionFile); - return $data ?: ''; + return $data ?: false; } - return ''; + return false; } /** diff --git a/src/Protocols/Http/Session/RedisClusterSessionHandler.php b/src/Protocols/Http/Session/RedisClusterSessionHandler.php index 685dc0334..d1f93d9b1 100644 --- a/src/Protocols/Http/Session/RedisClusterSessionHandler.php +++ b/src/Protocols/Http/Session/RedisClusterSessionHandler.php @@ -48,7 +48,7 @@ public function __construct($config) /** * {@inheritdoc} */ - public function read(string $sessionId): string + public function read(string $sessionId): string|false { return $this->redis->get($sessionId); } diff --git a/src/Protocols/Http/Session/RedisSessionHandler.php b/src/Protocols/Http/Session/RedisSessionHandler.php index f1fed758e..8733e068d 100644 --- a/src/Protocols/Http/Session/RedisSessionHandler.php +++ b/src/Protocols/Http/Session/RedisSessionHandler.php @@ -102,11 +102,11 @@ public function open(string $savePath, string $name): bool /** * {@inheritdoc} * @param string $sessionId - * @return string + * @return string|false * @throws RedisException * @throws Throwable */ - public function read(string $sessionId): string + public function read(string $sessionId): string|false { try { return $this->redis->get($sessionId); diff --git a/src/Protocols/Http/Session/SessionHandlerInterface.php b/src/Protocols/Http/Session/SessionHandlerInterface.php index 5e4a56eb5..03f6b35a0 100644 --- a/src/Protocols/Http/Session/SessionHandlerInterface.php +++ b/src/Protocols/Http/Session/SessionHandlerInterface.php @@ -74,14 +74,14 @@ public function open(string $savePath, string $name): bool; * Read session data * @link http://php.net/manual/en/sessionhandlerinterface.read.php * @param string $sessionId The session id to read data for. - * @return string

+ * @return string|false

* Returns an encoded string of the read data. - * If nothing was read, it must return an empty string. + * If nothing was read, it must return false. * Note this value is returned internally to PHP for processing. *

* @since 5.4.0 */ - public function read(string $sessionId): string; + public function read(string $sessionId): string|false; /** * Write session data