| 123456789101112131415161718192021222324252627 |
- <?php
- namespace App;
- class Session {
- public const ALERT_TYPE_INFO = "info";
- public const ALERT_TYPE_SUCCESS = "success";
- public const ALERT_TYPE_WARNING = "warning";
- public const ALERT_TYPE_DANGER = "danger";
- public static function addAlert(string $type, string $message): void {
- $alerts = $_SESSION["alerts"] ?? [];
- $alerts[] = [
- "type" => $type,
- "message" => $message
- ];
- $_SESSION["alerts"] = $alerts;
- }
- public static function getAlerts(): array {
- $alerts = $_SESSION["alerts"] ?? [];
- unset($_SESSION["alerts"]);
- return $alerts;
- }
- }
|