From 3236311e4a60d6d859b3d30a0700400d8693bd16 Mon Sep 17 00:00:00 2001 From: jdarwood007 Date: Fri, 3 Apr 2026 20:06:00 -0700 Subject: [PATCH 1/2] [3.0] Ensure we set the cookie when presenting the login form --- Sources/Actions/Login.php | 5 +++++ Sources/Actions/Login2.php | 1 + Sources/Forum.php | 3 +++ Sources/User.php | 4 ++++ 4 files changed, 13 insertions(+) diff --git a/Sources/Actions/Login.php b/Sources/Actions/Login.php index 1104f1fdda..b778b8b9cd 100644 --- a/Sources/Actions/Login.php +++ b/Sources/Actions/Login.php @@ -71,6 +71,11 @@ public function execute(): void 'name' => Lang::getTxt('login', file: 'General'), ]; + // Ensure the session data persists. + if (empty($_COOKIE)) { + Cookie::setLoginCookie(Cookie::LENGTH_DEFAULT, 0, ''); + } + // Set the login URL - will be used when the login process is done (but careful not to send us to an attachment). if (isset($_SESSION['old_url']) && !str_contains($_SESSION['old_url'], 'dlattach') && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) { $_SESSION['login_url'] = $_SESSION['old_url']; diff --git a/Sources/Actions/Login2.php b/Sources/Actions/Login2.php index d8e7cb8d58..8625bde552 100644 --- a/Sources/Actions/Login2.php +++ b/Sources/Actions/Login2.php @@ -257,6 +257,7 @@ public function main(): void // Cookies are required... if (empty($_COOKIE)) { + Cookie::setLoginCookie(Cookie::LENGTH_DEFAULT, 0, ''); Utils::$context['login_errors'] = [Lang::getTxt('login_cookie_error', file: 'Errors')]; return; diff --git a/Sources/Forum.php b/Sources/Forum.php index b5b618cad9..a0d3ed9728 100644 --- a/Sources/Forum.php +++ b/Sources/Forum.php @@ -728,6 +728,9 @@ protected function requireAgreement(): void protected static function inMaintenance(): void { Theme::loadTemplate('Login'); + if (empty($_COOKIE)) { + Cookie::setLoginCookie(Cookie::LENGTH_DEFAULT, 0, ''); + } SecurityToken::create('login'); // Send a 503 header, so search engines don't bother indexing while we're in maintenance mode. diff --git a/Sources/User.php b/Sources/User.php index a7e1231569..0649ff8e21 100644 --- a/Sources/User.php +++ b/Sources/User.php @@ -1578,6 +1578,10 @@ public function kickIfGuest(?string $message = null, bool $log = true): void // Load the Login template and language file. Theme::loadTemplate('Login'); + if (empty($_COOKIE)) { + Cookie::setLoginCookie(Cookie::LENGTH_DEFAULT, 0, ''); + } + // Create a login token. SecurityToken::create('login'); From d6f3e45532fb5b53d6a0edc1917b6dfbe1104617 Mon Sep 17 00:00:00 2001 From: jdarwood007 Date: Fri, 3 Apr 2026 20:11:30 -0700 Subject: [PATCH 2/2] cs fixes --- Sources/Forum.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/Forum.php b/Sources/Forum.php index a0d3ed9728..1b641f8dcf 100644 --- a/Sources/Forum.php +++ b/Sources/Forum.php @@ -728,6 +728,7 @@ protected function requireAgreement(): void protected static function inMaintenance(): void { Theme::loadTemplate('Login'); + if (empty($_COOKIE)) { Cookie::setLoginCookie(Cookie::LENGTH_DEFAULT, 0, ''); }