Jump to content

I can't get simple redirect to work


Go to solution Solved by floridaflatlander,

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

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

  • Solution

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.