floridaflatlander Posted June 29, 2013 Share Posted June 29, 2013 (edited) I can't get this simple redirect to work I put it at the beginning of a page to make sure all the needed session are present. I think the problem is in the user agent, I take that out and it works Say it's on website/member/index.php?id=1 and I change the user agent it doesn't redirect. It gives me a "This page can't be displayed" error on the same page website/member/index.php?id=1. function user_loggedin($home){ //if ($_SESSION['agent'] != md5($_SERVER['HTTP_USER_AGENT'])) echo 'NO Match'; else echo 'Match'; // for testing // If not fully logged in with required Sessions redirect if (!isset($_SESSION['id_member']) OR !isset($_SESSION['id_group']) OR !isset($_SESSION['agent']) OR ($_SESSION['agent'] != md5($_SERVER['HTTP_USER_AGENT']))) { header("Location: $home/members/login.php"); exit(); // Quit the script. } } Thanks Edited June 29, 2013 by floridaflatlander Quote Link to comment https://forums.phpfreaks.com/topic/279691-i-cant-get-simple-redirect-to-work/ Share on other sites More sharing options...
ginerjm Posted June 29, 2013 Share Posted June 29, 2013 Specifically - it's not the redirect that is failing you, is it? It is the series of tests you are making. Why not echo them all out and see what you have? That would be the best thing to show us to get help with. Quote Link to comment https://forums.phpfreaks.com/topic/279691-i-cant-get-simple-redirect-to-work/#findComment-1438523 Share on other sites More sharing options...
Solution floridaflatlander Posted June 29, 2013 Author Solution Share Posted June 29, 2013 Thanks for the reply ginerjm, no the conditions on the member page worked, the redirect also worked. The problem was on the login page if there was a session member id it would redirect back to the member page, the page the first redirect came from. I added ($_SESSION['agent'] == md5($_SERVER['HTTP_USER_AGENT'])) to the condition on the login page and it worked. Thanks again Quote Link to comment https://forums.phpfreaks.com/topic/279691-i-cant-get-simple-redirect-to-work/#findComment-1438560 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.