From 26c56cf0e8b4035dd798eb0331b4257402bfc94a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Cort=C3=A9s=20Cano?= <38475681+TrapoSAMA@users.noreply.github.com> Date: Wed, 22 Jul 2026 03:55:32 -0400 Subject: [PATCH] Keep 4.x login CSRF token stable across repeated GETs (#1087) Do not recreate the CSRF token in the session if one already exists, this should avoid people seeing an expired CSRF token error thanks @TrapoSAMA --- public/login.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/public/login.php b/public/login.php index 78dd97ab..19174dc4 100644 --- a/public/login.php +++ b/public/login.php @@ -109,7 +109,10 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { session_start(); } -$_SESSION['PFA_token'] = md5(uniqid("pfa" . rand(), true)); +if (empty($_SESSION['PFA_token'])) { + // Keep the login token stable across repeated GETs in this session. + $_SESSION['PFA_token'] = md5(uniqid("pfa" . rand(), true)); +} $smarty->assign('language_selector', language_selector(), false); $smarty->assign('smarty_template', 'login');