From b50e38fe2cda7225a6e82de29b326f9d65f1726f Mon Sep 17 00:00:00 2001
From: Dimitris Bozelos <dbozelos@gmail.com>
Date: Thu, 23 Feb 2023 02:14:13 +0000
Subject: [PATCH] Issue #3343859 Session storage methods should not rely on
 cache

---
 src/Session/SessionStorage.php | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/Session/SessionStorage.php b/src/Session/SessionStorage.php
index 243c4a1..28e8091 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());
   }
 
   /**
-- 
GitLab