Q: Stop direct access to .html pages without , redirect to login.php I've been looking for an answer to make all my other .html pages in the root directory(or outside of) to be checked against if a session has taken place or not. If not direct visitor back to index.php (where login is, set in public_html).
Does anyone have a work around for this?  If so where would I put the "if no session redirect"?
So if someone just goes directly to www.site.com/here.html the php runs and see's if the session had been instated, if not redirects to www.site.com/login.php.

A: Use this:
<?php
if(!session_id()){
    header('Location: /index.php');
    exit;
}
?>

Just place it at the top of your html file
Or to be on the safe side, check if an index in the session is set like:
if(!isset($_SESSION['user'])){
    // redirect code
}

For this to work, on user login, you need to set 
$_SESSION['user'] = 'something'; // a real value here!


A: Ok Alex, this is what I came up with but haven't ran it yet.  Just looking for if I'm even coming close.
Surely I'm not, this is my first go at adding this type of functionality to a site.
<?php
    function menuOptions($menuOptions)
  {
    $menu1 = array(
        'Marketing Dept.' =>('text'=>'Marketing Dept.', 'Welcome.html'=>'?p=home'),
        'Printing' =>('text'=>'Printing', 'Printing.html'=>'?p=Printing'),
        'Email Marketing' =>('text'=>'Email Marketing', 'Emailing.html'=>'?p=Emailing'),
        'Website Development' =>('text'=>'Website Development', 'Website.html'=>'?p=Website'),
        'Help' =>('text'=>'Help', 'Help.html'=>'?p=Help'),
        'Logout' =>('text'=>'Logout', 'logout.php'=>'?p=Logout'),
    );
    $menu2 = array(
        'Marketing Dept.' =>('text'=>'Marketing Dept.', 'Welcome.html'=>'?p=home'),
        'Printing' =>('text'=>'Printing', 'Printing.html'=>'?p=Printing'),
        'Email Marketing' =>('text'=>'Email Marketing', 'Emailing.html'=>'?p=Emailing'),
        'Website Development' =>('text'=>'Website Development', 'Website.html'=>'?p=Website'),
        'Marketing-Projects' =>('text'=>'Marketing-Projects', 'Marketing-Projects.html'=>'?p=Marketing-Projects'),
        'MarketingSchedules' =>('text'=>'Marketing Department Schedules', 'MarketingSchedules.html'),   
        'MarketingDepartmentSchedules' =>('text'=>"Marketing Department Schedules, MarketingDepartmentSchedules.html"),
        'Help' =>('text'=>'Help', 'Help.html'=>'?p=Help'),
        'Logout' =>('text'=>'Logout', 'logout.php'=>'?p=Logout'),
    );
    $menu3 = array(
        'Marketing Dept.' =>('text'=>'Marketing Dept.', 'Welcome.html'=>'?p=home'),
        'Printing' =>('text'=>'Printing', 'Printing.html'=>'?p=Printing'),
        'Email Marketing' =>('text'=>'Email Marketing', 'Emailing.html'=>'?p=Emailing'),
        'Website Development' =>('text'=>'Website Development', 'Website.html'=>'?p=Website'),
        'Marketing-Projects' =>('text'=>'Marketing-Projects', 'Marketing-Projects.html'=>'?p=Marketing-Projects'),
        'MarketingSchedules' =>('text'=>'Marketing Department Schedules', 'MarketingSchedules.html'),   
        'MarketingDepartmentSchedules' =>('text'=>"Marketing Department Schedules, MarketingDepartmentSchedules.html"),
        'MarketingExpenseReports' =>('text'=>"Marketing Expense Reports", 'MarketingExpenseReports.php'),
        'Help' =>('text'=>'Help', 'Help.html'=>'?p=Help'),
        'Logout' =>('text'=>'Logout', 'logout.php'=>'?p=Logout'),
    );
    $menuAdmin = array(
        'Marketing Dept.' =>('text'=>'Marketing Dept.', 'Welcome.html'=>'?p=home'),
        'Printing' =>('text'=>'Printing', 'Printing.html'=>'?p=Printing'),
        'Email Marketing' =>('text'=>'Email Marketing', 'Emailing.html'=>'?p=Emailing'),
        'Website Development' =>('text'=>'Website Development', 'Website.html'=>'?p=Website'),
        'Marketing-Projects' =>('text'=>'Marketing-Projects', 'Marketing-Projects.html'=>'?p=Marketing-Projects'),
        'MarketingSchedules' =>('text'=>'Marketing Department Schedules', 'MarketingSchedules.html'),   
        'MarketingDepartmentSchedules' =>('text'=>"Marketing Department Schedules, MarketingDepartmentSchedules.html"),
        'MarketingExpenseReports' =>('text'=>"Marketing Expense Reports", 'MarketingExpenseReports.php'),
        'Help' =>('text'=>'Help', 'Help.html'=>'?p=Help'),
        'Logout' =>('text'=>'Logout', 'logout.php'=>'?p=Logout'),
    );
}


    function aprovedusers($aprovedusers)
{
    // setting aproved users list 1 for sales department
    $aprovedusers1=array("user1");

    // setting aproved users list 2
    $aprovedusers2=array("user1","user2");

    // setting aproved users list 3 for marketing department
    $aprovedusers3=array("user1","user2","user3");

    // setting aproved users list admin for admin
    $aprovedusersAdmin=array("Admin1");

    $msg1 = echo "hello";
    $msg2 = echo "must login";
    $msg3 = echo "hello Marketing";
    $msg4 = echo "hello Admin";

}

function getloggedin($userloggedin)
{
    if($_SESSION['userlogin'] == ''){
    echo $msg1 'userlogin';
    } else {
    header("Location: logout.php");
}
echo $msg2;




  echo '<div id="'. $userlogin .'">';

 ?>
 <html lang="en">
 <head>
  <meta charset="UTF-8">
  <title>Markting Home</title>
 </head>
 <header>
   <div id="Menu">
    <div id="<?php echo $userloggedin ?>" >
        <?php //show only approved menu for what menu user is approved for ?>
        <div id="<?php echo $menuOptions ?>" >
            <div><?php echo $menu1?></div>
            <div><?php echo $menu2?></div>
            <div><?php echo $menu3?></div>
            <div><?php echo $menuAdmin?></div>
        </div>
    </div>
   </div>
     <body>
       <div id="content">
     </div>
   </body>
  </header>

I'll be working on it all night learning as I go if you have any pointers that would great!
