I have a routine that I used to prevent users from going directly to a php page without first logging in. The code merely asks if the user has an access_level set. If the user does not, then the user is bounced back to the log in window. It works about 95% of the time and always in this manner:
The user successfully logs in and is directed to the home page that has the access_level check. The successful user is never bounced when going to the home page. But, when the user chooses an a php page to visit from the navigation menu, 5% of the time he will get bounced back into login. I've tested it a dozen times and I can't detect anything that I am doing differently between logins that would cause it to sometimes fail.
The routine looks like this:
if (!isset($_SESSION['access_level'])) {
$err_msg='Illegal access--user not logged in';
include('userlogin.php');
exit();
}
I've also tried it with empty and get the same results.
I can't figure out why it usually works, an occasionally fails. Any ideas?