You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
654 B

<?php
namespace App\Wrappers;
use App\Enumerators\SessionElement;
class SessionWrapper
{
public static function Start(): void
{
if (session_status() == PHP_SESSION_NONE)
{
session_start();
}
}
public static function Get(SessionElement $target): mixed
{
self::Start();
if(array_key_exists(key: $target->value, array: $_SESSION))
{
return $_SESSION[$target->value];
}
die();
}
public static function Set(SessionElement $target, mixed $newValue): void
{
self::Start();
$_SESSION[$target->value] = $newValue;
}
}