summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2025-12-10 18:57:32 +0500
committerilotterytea <iltsu@alright.party>2025-12-10 18:57:32 +0500
commitf32b2094b304fa7832a8931b08a5bbb9cd1076eb (patch)
tree76a7a9f4ca724590f4dccb69758b550c180a9272
parentb62ba9a6b7a17dd85ea2f8dd20ccc08187c0de62 (diff)
upd: store alert data in PHP session
-rw-r--r--lib/alert.php18
1 files 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);
</script>
- <?php
+ <?php ;
} \ No newline at end of file