<?php
require_once __DIR__. '/SessionManagementService.php';
require_once __DIR__. '/UserService.php';
require_once __DIR__. '/Util.php';

$session_management_service = new SessionManagementService();
$base_url = Util::getLastSegment($_SERVER['REQUEST_URI']);

if($session_management_service->isLoggedIn()){
    if($base_url == 'index.php'){
        header('Location: dashboard.php');
    }
} else if ($base_url != 'index.php'){
    header('Location: index.php?message=Please+Login.');
}
?>