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] Link to comment https://forums.phpfreaks.com/topic/30379-easy-problem-for-somone/ 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] Link to comment https://forums.phpfreaks.com/topic/30379-easy-problem-for-somone/#findComment-139780 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). Link to comment https://forums.phpfreaks.com/topic/30379-easy-problem-for-somone/#findComment-139807 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. Link to comment https://forums.phpfreaks.com/topic/30379-easy-problem-for-somone/#findComment-139915 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.