garry27 Posted December 12, 2006 Share Posted December 12, 2006 is there anything wrong with the code below. i want to redirect the user if neither of the two session vars are set. i'm pretty sure its a logical problem with the code below.[code]if ( !isset($_SESSION['valid_pa_mbr']) && !isset($_SESSION['valid_ba_mbr']) ) { $url = "login.php"; header ("Location: $url");}[/code] Quote Link to comment Share on other sites More sharing options...
utexas_pjm Posted December 12, 2006 Share Posted December 12, 2006 That code will do what you specified. You might want to be a tad more rigorous in checking that the data is not garbage, e.g., write a function that validates the data and redirect based on it's results.[code]if ( is_valid_pa_mbr($_SESSION['valid_pa_mbr']) && is_valid_ba_mbr($_SESSION['valid_ba_mbr']) ) { $url = "login.php"; header ("Location: $url");}[/code] Quote Link to comment Share on other sites More sharing options...
garry27 Posted December 12, 2006 Author Share Posted December 12, 2006 thanks mate, that's what i thought! the problem's sorted itself out now anyway. i'm not sure what i did to fix it but the login functionality works again. the code i specified only checks whether the user is logged on, and redirects the user to a login page if he/she isn't logge on (i.e no session variable set). Quote Link to comment Share on other sites More sharing options...
boby Posted December 12, 2006 Share Posted December 12, 2006 Make sure there is no output made before you send the redirect header or it won't work. Quote Link to comment Share on other sites More sharing options...
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.