It works...but instead of putting the code at the top of every page...create an authentication.php file and require it at the top of every page.