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..1b641f8dcf 100644 --- a/Sources/Forum.php +++ b/Sources/Forum.php @@ -728,6 +728,10 @@ 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');