Skip to content

Commit 79a43ba

Browse files
authored
Merge pull request #9178 from jdarwood007/3.0/fix9158
[3.0] Ensure we set the cookie when presenting the login form
2 parents a7875e8 + d6f3e45 commit 79a43ba

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

Sources/Actions/Login.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ public function execute(): void
7171
'name' => Lang::getTxt('login', file: 'General'),
7272
];
7373

74+
// Ensure the session data persists.
75+
if (empty($_COOKIE)) {
76+
Cookie::setLoginCookie(Cookie::LENGTH_DEFAULT, 0, '');
77+
}
78+
7479
// Set the login URL - will be used when the login process is done (but careful not to send us to an attachment).
7580
if (isset($_SESSION['old_url']) && !str_contains($_SESSION['old_url'], 'dlattach') && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) {
7681
$_SESSION['login_url'] = $_SESSION['old_url'];

Sources/Actions/Login2.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ public function main(): void
257257

258258
// Cookies are required...
259259
if (empty($_COOKIE)) {
260+
Cookie::setLoginCookie(Cookie::LENGTH_DEFAULT, 0, '');
260261
Utils::$context['login_errors'] = [Lang::getTxt('login_cookie_error', file: 'Errors')];
261262

262263
return;

Sources/Forum.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,10 @@ protected function requireAgreement(): void
728728
protected static function inMaintenance(): void
729729
{
730730
Theme::loadTemplate('Login');
731+
732+
if (empty($_COOKIE)) {
733+
Cookie::setLoginCookie(Cookie::LENGTH_DEFAULT, 0, '');
734+
}
731735
SecurityToken::create('login');
732736

733737
// Send a 503 header, so search engines don't bother indexing while we're in maintenance mode.

Sources/User.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,6 +1578,10 @@ public function kickIfGuest(?string $message = null, bool $log = true): void
15781578
// Load the Login template and language file.
15791579
Theme::loadTemplate('Login');
15801580

1581+
if (empty($_COOKIE)) {
1582+
Cookie::setLoginCookie(Cookie::LENGTH_DEFAULT, 0, '');
1583+
}
1584+
15811585
// Create a login token.
15821586
SecurityToken::create('login');
15831587

0 commit comments

Comments
 (0)