diff --git a/Sources/LogInOut.php b/Sources/LogInOut.php index 93946ec1c0..404102e2a3 100644 --- a/Sources/LogInOut.php +++ b/Sources/LogInOut.php @@ -27,7 +27,7 @@ */ function Login() { - global $txt, $context, $scripturl, $user_info; + global $txt, $context, $scripturl, $user_info, $modSettings; // You are already logged in, go take a tour of the boards if (!empty($user_info['id'])) @@ -82,6 +82,11 @@ function Login() 'name' => $txt['login'], ); + // Ensure the session data persists. + if (empty($_COOKIE)) { + setLoginCookie(60 * $modSettings['cookieTime'], 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']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) $_SESSION['login_url'] = $_SESSION['old_url']; @@ -263,6 +268,7 @@ function Login2() // Cookies are required... if (empty($_COOKIE)) { + setLoginCookie(60 * $modSettings['cookieTime'], 0, ''); $context['login_errors'] = array($txt['login_cookie_error']); return; } diff --git a/Sources/Subs-Auth.php b/Sources/Subs-Auth.php index e0d44f25b4..d9950238a1 100644 --- a/Sources/Subs-Auth.php +++ b/Sources/Subs-Auth.php @@ -210,11 +210,14 @@ function url_parts($local, $global) */ function KickGuest() { - global $txt, $context; + global $txt, $context, $modSettings; loadTheme(); loadLanguage('Login'); loadTemplate('Login'); + if (empty($_COOKIE)) { + setLoginCookie(60 * $modSettings['cookieTime'], 0, ''); + } createToken('login'); // Never redirect to an attachment @@ -232,10 +235,13 @@ function KickGuest() */ function InMaintenance() { - global $txt, $mtitle, $mmessage, $context, $smcFunc; + global $txt, $mtitle, $mmessage, $context, $smcFunc, $modSettings; loadLanguage('Login'); loadTemplate('Login'); + if (empty($_COOKIE)) { + setLoginCookie(60 * $modSettings['cookieTime'], 0, ''); + } createToken('login'); // Send a 503 header, so search engines don't bother indexing while we're in maintenance mode.