1
0

Session.php 569 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace App;
  3. class Session {
  4. public const ALERT_TYPE_INFO = "info";
  5. public const ALERT_TYPE_SUCCESS = "success";
  6. public const ALERT_TYPE_WARNING = "warning";
  7. public const ALERT_TYPE_DANGER = "danger";
  8. public static function addAlert(string $type, string $message): void {
  9. $alerts = $_SESSION["alerts"] ?? [];
  10. $alerts[] = [
  11. "type" => $type,
  12. "message" => $message
  13. ];
  14. $_SESSION["alerts"] = $alerts;
  15. }
  16. public static function getAlerts(): array {
  17. $alerts = $_SESSION["alerts"] ?? [];
  18. unset($_SESSION["alerts"]);
  19. return $alerts;
  20. }
  21. }