MrFish Posted January 12, 2010 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. Link to comment Share on other sites More sharing options...
jlhaslip Posted January 12, 2010 Share Posted January 12, 2010 where is the code for this function?checkUser() Link to comment Share on other sites More sharing options...
Synook Posted January 12, 2010 Share Posted January 12, 2010 Setting a header won't cause the script to halt execution, you need to use exit() for that. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.