ok i figured it out. if anyone else runs into a problem like this i hope it helps.
in my original code i did the following.
<?PHP
session_start();
<set variables>
<connected to database>
if(isset($_SESSION['user_id'])) {
<query the database or something>
} else {
echo "you have failed to login";
// User not logged in
header('location: http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).'index.php');
exit();
}
?>
then it hit me that why would i establish a connection to the database before i validate that the user has logged in. i moved that information into the if statement and wala everything worked.
<?PHP
session_start();
if(isset($_SESSION['user_id'])) {
<set variables>
<connected to database>
<query the database or something>
} else {
echo "you have failed to login";
// User not logged in
header('location: http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).'index.php');
exit();
}
?>