25 lines
		
	
	
		
			650 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
		
			650 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
require_once "globals.php";
 | 
						|
 | 
						|
require_once "class/UserMgr.php";
 | 
						|
 | 
						|
// attempt to auto-login
 | 
						|
$autologin_user_data = [];
 | 
						|
$auto_logged_in = false;
 | 
						|
if ((session_status() === PHP_SESSION_ACTIVE) && isset($_SESSION["nickname"])) {
 | 
						|
    $usrMgr = new UserMgr();
 | 
						|
    $autologin_user = $usrMgr->getUser($_SESSION["nickname"]);
 | 
						|
    $auto_logged_in = $autologin_user !== null;
 | 
						|
    $autologin_user_data = $autologin_user->toArray(["password"]);
 | 
						|
}
 | 
						|
 | 
						|
function get_autologin_state() : bool {
 | 
						|
    global $auto_logged_in;
 | 
						|
    return $auto_logged_in;
 | 
						|
}
 | 
						|
 | 
						|
function get_autologin_user_data() : array {
 | 
						|
    global $autologin_user_data;
 | 
						|
    return $autologin_user_data;
 | 
						|
} |