From f32b2094b304fa7832a8931b08a5bbb9cd1076eb Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Wed, 10 Dec 2025 18:57:32 +0500 Subject: upd: store alert data in PHP session --- lib/alert.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/alert.php b/lib/alert.php index 2983378..300d58c 100644 --- a/lib/alert.php +++ b/lib/alert.php @@ -11,18 +11,26 @@ function generate_alert(string $path, string $error, int $status = 400) "data" => null ]); } else { - header("Location: $path" . (str_contains($path, "?") ? "&" : "?") . "error_status=$status&error_reason=$error"); + session_start(); + $_SESSION['alert'] = [ + 'code' => $status, + 'reason' => $error + ]; + header("Location: $path"); } } function display_alert() { - if (!isset($_GET["error_status"], $_GET["error_reason"])) { + if (!isset($_SESSION["alert"])) { return; } - $status = $_GET["error_status"]; - $reason = str_safe($_GET["error_reason"], 100); + $alert = $_SESSION["alert"]; + unset($_SESSION["alert"]); + + $status = $alert["code"]; + $reason = str_safe($alert["reason"], 100); $ok = substr($status, 0, 1) == '2'; echo '' ?> @@ -36,5 +44,5 @@ function display_alert() alertBox.remove(); }, 5000); -