summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-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