Your IP : 216.73.216.165
<?php
// auth.php
require_once 'config.php';
class Authentication
{
public static function login($username, $password)
{
if ($username === ADMIN_USERNAME && password_verify($password, ADMIN_PASSWORD_HASH)) {
$_SESSION['admin_logged_in'] = true;
$_SESSION['login_time'] = time();
return true;
}
return false;
}
public static function logout()
{
$_SESSION = array();
session_destroy();
header('Location: login.php');
exit;
}
public static function isLoggedIn()
{
return isset($_SESSION['admin_logged_in']) && $_SESSION['admin_logged_in'] === true;
}
public static function requireAuth()
{
if (!self::isLoggedIn()) {
header('Location: login.php');
exit;
}
}
}