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
https://forums.phpfreaks.com/topic/30379-easy-problem-for-somone/
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]
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).

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.