dj_mix_hosting_software/classes/SessionManager.php
Cody Cook 8f3061ab99
Some checks failed
SonarQube Scan / SonarQube Trigger (push) Failing after 5m39s
Language updates. New upload form. new classes.
2025-02-22 00:20:39 -08:00

40 lines
765 B
PHP

<?php
namespace DJMixHosting;
class SessionManager {
/**
* Ensure the session is started.
*/
public static function start() {
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
}
/**
* Set user data in session.
*/
public static function setUser(array $userData) {
$_SESSION['user'] = $userData;
}
/**
* Retrieve the current user data from session.
*/
public static function getUser() {
return $_SESSION['user'] ?? null;
}
/**
* Destroy the session.
*/
public static function destroy() {
if (session_status() !== PHP_SESSION_NONE) {
session_unset();
session_destroy();
}
}
}