diff --git a/src/Session/SessionStorage.php b/src/Session/SessionStorage.php index 243c4a1eef69bbe707818959c50a4ebbd591303b..28e80918379a315180224423083d225b02fe10a0 100644 --- a/src/Session/SessionStorage.php +++ b/src/Session/SessionStorage.php @@ -88,10 +88,10 @@ class SessionStorage implements SessionStorageInterface { public function exists( string $id = SessionInterface::SESSION_ID_DEFAULT ): bool { - // Creating/deleting sessions should always happen through the interface - // provided by this storage. We therefore do not need to actually load the - // session from the storage. - return isset($this->cache[$id]); + // We don't check existing in the cache because we load sessions as + // requested. There may therefore exist sessions in the store that do not + // yet exist in the cache. + return $this->store->has($id); } /** @@ -106,10 +106,10 @@ class SessionStorage implements SessionStorageInterface { * {@inheritdoc} */ public function getCount(): int { - // Creating/deleting sessions should always happen through the interface - // provided by this storage. We therefore do not need to actually load the - // sessions from the storage. - return count(array_filter($this->cache)); + // We don't get the count from the cache because we load sessions as + // requested. There may therefore exist sessions in the store that do not + // yet exist in the cache. + return count($this->store->getAll()); } /**