Mam problem z klasą sesji, a konkretnie metodą `wantsIssetSession` która sprawdza czy sesja jest ustawiona. Pojawia się błąd Warning: Undefined variable $_SESSION in C:\xampp8.0\htdocs\messbox\messbox-_project\photo.php on line 14.
Fatal error: Uncaught TypeError: Mess\Session\Session::__construct(): Argument #1 ($session) must be of type array, null given, called in C:
Czy ktoś mógłby mi pomóc rozwiązać ten problem ?
class Session
{
private array $session;
public function __construct(array $session)
{
$this->session = $session;
}
public function startSession(): bool
{
return session_start();
}
public function wantsIssetSession(): bool
{
return isset($this->session['user_id']);
}
}
$session = new Session($_SESSION);
$start = $session->startSession();
$fill = $session->wantsIssetSession();
if ($fill) {
Przykladowy kod
}else
header(index.php);