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.


Link to comment
Share on other sites

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.

Link to comment
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

Link to comment
Share on other sites


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.