inexplicable problem
Posted: Sun Jan 21, 2007 3:43 pm
i've go this function which i add to all my pages which is meant to check if user is logged in and if they're not redirect them to a login page. It works in so far as blocking acess to all users- whether they're logged in or not.
it's also meant to show a link to the logout page but it doesn't - it shows the the text in link format but ther'e no link. i've echoed out the session variables assigned to the user name so you can see that the sesh vars are ok:
you can see it in action here (sign in with 'personal' for email 'account' for password):
http://www.nl-webspace.co.uk/~unn_p921847/t2/login.php
now here's the same example with the condition swithched so that if the user is logged in it redirects and if he isn't logged in he can roam around only this way the damn thing works as it should:
changed to
http://www.nl-webspace.co.uk/~unn_p921847/t3/login.php
please somone explain before i go mad!
it's also meant to show a link to the logout page but it doesn't - it shows the the text in link format but ther'e no link. i've echoed out the session variables assigned to the user name so you can see that the sesh vars are ok:
Code: Select all
function check_login()
{
//add logout link if user logged in
if (isset($_SESSION['valid_pa_mbr']) || isset($_SESSION['valid_ba_mbr']) ) {
echo "<a href='logout.php' id='logout-msg' >Log out</a>";
}
if ( $_SERVER['PHP_SELF'] == '/~unn_p921847/t1/index.php' ) {
return;
}
echo 'tgtgttg ' . $_SESSION['valid_pa_mbr'];
echo 'kukukuk ' . $_SESSION['valid_ba_mbr'];
//redirect to login page if no log in session
if (!isset($_SESSION['valid_pa_mbr']) || !isset($_SESSION['valid_ba_mbr']) ) {
$url = "login.php";
header ("Location: $url");
}http://www.nl-webspace.co.uk/~unn_p921847/t2/login.php
now here's the same example with the condition swithched so that if the user is logged in it redirects and if he isn't logged in he can roam around only this way the damn thing works as it should:
Code: Select all
if (!isset($_SESSION['valid_pa_mbr']) || !isset($_SESSION['valid_ba_mbr']) ) {Code: Select all
if (isset($_SESSION['valid_pa_mbr']) || isset($_SESSION['valid_ba_mbr']) ) {please somone explain before i go mad!