MrFish 9 Posted January 12, 2010 Report Share Posted January 12, 2010 I've written some functions for my forum to make it easier to handle users. I thought it was working fine until I checked the database and found that even if my script called to redirect an unlogged in user, all the other scripts in the code were ran.The function- function checkUserStrict() //Checks if the visitor is logged in{ if(!isset($_SESSION["username"])) { $x = checkUser(); if($x == 0) header( "Location: loginforms.php" ); }} The page that calls the function- include("includes/universalfunctions.php"); checkUserStrict(); header( "Location: index.php" ); The function works fine, it will redirect me if I am not logged in. But I tested it by adding another redirect after the function. I immediately go to the index page when accessing this page. How do I tell the code to wait until it finishes the check. Quote Link to post Share on other sites
jlhaslip 1 Posted January 12, 2010 Report Share Posted January 12, 2010 where is the code for this function?checkUser() Quote Link to post Share on other sites
Synook 47 Posted January 12, 2010 Report Share Posted January 12, 2010 Setting a header won't cause the script to halt execution, you need to use exit() for that. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.