From a411e0a45b2be90561b50fad48b095c6b726b7cd Mon Sep 17 00:00:00 2001 From: Aleksi Peebles Date: Thu, 29 Feb 2024 17:03:34 +0200 Subject: [PATCH 1/2] Early return from SessionManager::destroy() if headers have already been sent Signed-off-by: Aleksi Peebles --- src/SessionManager.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/SessionManager.php b/src/SessionManager.php index ef7d967a..1a9b5cc1 100644 --- a/src/SessionManager.php +++ b/src/SessionManager.php @@ -198,6 +198,10 @@ public function destroy(?array $options = null) return; } + if (headers_sent()) { + return; + } + if (null === $options) { $options = $this->defaultDestroyOptions; } else { From dcf8fe8915416de91af455f94dc275f423014131 Mon Sep 17 00:00:00 2001 From: Aleksi Peebles Date: Thu, 29 Feb 2024 17:22:59 +0200 Subject: [PATCH 2/2] Even earlier return Signed-off-by: Aleksi Peebles --- src/SessionManager.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/SessionManager.php b/src/SessionManager.php index 1a9b5cc1..152c0bae 100644 --- a/src/SessionManager.php +++ b/src/SessionManager.php @@ -194,11 +194,7 @@ protected function initializeValidatorChain() */ public function destroy(?array $options = null) { - if (! $this->sessionExists()) { - return; - } - - if (headers_sent()) { + if (headers_sent() || ! $this->sessionExists()) { return; }