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.
		
		
		
		
		
			
		
			
				
					
					
						
							37 lines
						
					
					
						
							818 B
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							37 lines
						
					
					
						
							818 B
						
					
					
				
								<?php
							 | 
						|
								
							 | 
						|
								namespace App\Wrappers;
							 | 
						|
								
							 | 
						|
								use App\Enumerators\SessionElement;
							 | 
						|
								
							 | 
						|
								class SessionWrapper
							 | 
						|
								{
							 | 
						|
								    public static function Start(): void
							 | 
						|
								    {
							 | 
						|
								        if (session_status() == PHP_SESSION_NONE)
							 | 
						|
								        {
							 | 
						|
								            session_start();
							 | 
						|
								            if(!isset($_SESSION[SessionElement::IS_LOGGED_IN->value]))
							 | 
						|
								            {
							 | 
						|
								                self::Set(SessionElement::IS_LOGGED_IN, false);
							 | 
						|
								            }
							 | 
						|
								        }
							 | 
						|
								
							 | 
						|
								    }
							 | 
						|
								
							 | 
						|
								    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;
							 | 
						|
								    }
							 | 
						|
								}
							 | 
						|
								
							 |