<?php

require_once 'initialize.php';
$userLogin = new LoginOptions();
$userCheck = new UsernameValidator();
$passCheck = new PasswordValidator();
$errorMan = new ErrorManager();
session_start();
$user = '';
$pass = '';
if (isset($_SESSION['username'])) {
    $userLogin->isLoggedIn();
}
if (isset($_POST['username'])) {
    $user = $_POST['username'];
}
if (isset($_POST['password'])) {
    $pass = $_POST['password'];
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if ($passCheck->isValid($pass)) {
        if ($userCheck->isValid($user)) {
            $_SESSION['username'] = $user;
            $userLogin->isLoggedIn();
        } else {
            $errorMan->addError($user, 'Invalid Username. Username should be 5 alphabetic characters.');
        }
    } elseif ($userCheck->isValid($user)) {
        $errorMan->addError($pass, 'Invalid Password. Password should be at least 5 alpha numeric characters.');
    } else {
        $errorMan->addError($user, 'Invalid Username. Username should be 5 alphabetic characters.');
<?php

require_once 'initialize.php';
$user = new LoginOptions();
session_start();
$username = '';
if (isset($_SESSION['username'])) {
    $username = $_SESSION['username'];
    echo $username . ", you are being logged.";
    $user->logout();
    header("Refresh: 3; url=index.php");
    exit;
} else {
    header("Location: index.php");
    exit;
}
<?php

require_once 'initialize.php';
$userLogin = new LoginOptions();
session_start();
$user = '';
if (isset($_SESSION['username'])) {
    $user = $_SESSION['username'];
}
if (strlen($user) < 5) {
    $userLogin->isNotLoggedIn();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<div>Hello <?php 
echo $user;
?>
.</div> 
	<br>
	<div><a href="logout.php">Logout here.</a></div>
</body>
</html>