Avoid restarting anonymous login sessions on 4.x (#1086)

Restrict recreating $_SESSION to only those where the user has been logged in previously; this should help stop anonymous users from failing a CSRF check.

thanks @TrapoSAMA
This commit is contained in:
Rodrigo Cortés Cano authored and GitHub committed 2026-07-22 08:51:38 +01:00
1 parent db376c92a4
commit bfe0b8cfd0
1 file changed
+3 -1
+3 -1
View File
@@ -101,7 +101,9 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
error_log("PostfixAdmin admin login failed (username: $fUsername, ip_address: {$_SERVER['REMOTE_ADDR']})");
flash_error($PALANG['pLogin_failed']);
}
} else {
} elseif (isset($_SESSION['sessid'])) {
// Do not restart anonymous sessions while rendering the login form.
// An existing authenticated session should still be cleared before login.
session_unset();
session_destroy();
session_start();