07-30-db/authUser.php
<?php

/*use PHP session variables*/
session_start();

/*check if the user is already logged in*/
/*try to set session variables based on cookies if possible*/
if (!isset($_SESSION['userID'])) {
    /*CHECK IF THE COOKIES ARE SET AND IF SO, COPY THEM INTO THE SESSION VARIABLES*/
    if (isset($_COOKIE['userID']) && isset($_COOKIE['userName'])) {
        $_SESSION['userID'] = $_COOKIE['userID'];
        $_SESSION['userName'] = $_COOKIE['userName'];
    }
}

if (!isset($_SESSION['userID'])) {
    header('Location: login.php');
    exit();
}
?>