Jump to content

easy problem for somone


garry27

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

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.