Jump to content

I can't get simple redirect to work


Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/279691-i-cant-get-simple-redirect-to-work/
Share on other sites

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.