Skip to content

Commit 375bcd1

Browse files
authored
Merge pull request #9167 from jdarwood007/fix9158
[2.1] Ensure we set the cookie when presenting the login form
2 parents 7d048f8 + 44b6312 commit 375bcd1

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

Sources/LogInOut.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
*/
2828
function Login()
2929
{
30-
global $txt, $context, $scripturl, $user_info;
30+
global $txt, $context, $scripturl, $user_info, $modSettings;
3131

3232
// You are already logged in, go take a tour of the boards
3333
if (!empty($user_info['id']))
@@ -82,6 +82,11 @@ function Login()
8282
'name' => $txt['login'],
8383
);
8484

85+
// Ensure the session data persists.
86+
if (empty($_COOKIE)) {
87+
setLoginCookie(60 * $modSettings['cookieTime'], 0, '');
88+
}
89+
8590
// Set the login URL - will be used when the login process is done (but careful not to send us to an attachment).
8691
if (isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0)
8792
$_SESSION['login_url'] = $_SESSION['old_url'];
@@ -263,6 +268,7 @@ function Login2()
263268
// Cookies are required...
264269
if (empty($_COOKIE))
265270
{
271+
setLoginCookie(60 * $modSettings['cookieTime'], 0, '');
266272
$context['login_errors'] = array($txt['login_cookie_error']);
267273
return;
268274
}

Sources/Subs-Auth.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,14 @@ function url_parts($local, $global)
210210
*/
211211
function KickGuest()
212212
{
213-
global $txt, $context;
213+
global $txt, $context, $modSettings;
214214

215215
loadTheme();
216216
loadLanguage('Login');
217217
loadTemplate('Login');
218+
if (empty($_COOKIE)) {
219+
setLoginCookie(60 * $modSettings['cookieTime'], 0, '');
220+
}
218221
createToken('login');
219222

220223
// Never redirect to an attachment
@@ -232,10 +235,13 @@ function KickGuest()
232235
*/
233236
function InMaintenance()
234237
{
235-
global $txt, $mtitle, $mmessage, $context, $smcFunc;
238+
global $txt, $mtitle, $mmessage, $context, $smcFunc, $modSettings;
236239

237240
loadLanguage('Login');
238241
loadTemplate('Login');
242+
if (empty($_COOKIE)) {
243+
setLoginCookie(60 * $modSettings['cookieTime'], 0, '');
244+
}
239245
createToken('login');
240246

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

0 commit comments

Comments
 (0)