- Small fixes made to session

This commit is contained in:
Dave Mc Nicoll 2026-05-21 15:01:15 +00:00
parent 4fbf91e940
commit 3bc53f02e5

View File

@ -8,17 +8,22 @@ use session_name, session_id, session_start, session_destroy, session_save_path,
class Session class Session
{ {
public static function get($key, $default = null) public static function get($key, $default = null) : mixed
{ {
return static::has($key) ? $_SESSION[$key] : $default; return static::has($key) ? $_SESSION[$key] : $default;
} }
public static function set($key, $value) public static function define($key, $value) : bool
{
return static::has($key) ? false : static::set($key, $value) || true;
}
public static function set($key, $value) : mixed
{ {
return $_SESSION[$key] = $value; return $_SESSION[$key] = $value;
} }
public static function delete($key) public static function delete($key) : void
{ {
unset($_SESSION[$key]); unset($_SESSION[$key]);
} }