07-03-2008, 10:06 PM
|
#5 (permalink)
|
|
The Gregarious
Join Date: Mar 2008
Location: Cana'derr
Posts: 653
Thanks: 24
|
Something like that yes, have you tried it to see if it works?
It appears to me that the only session variable you're setting when a user logs in is "logged" so unless you're making sure to set those new variables (loginid and username), that'll return false everytime.
Also, since the if->else block will return either true or false, you'll never get to the third return so it becomes unnecessary. Here's three random ways you could write the same function, just to give you an idea of how flexible PHP can be with nearly everything;
PHP Code:
function isLoggedIn() { $bLoggedIn = false;
if (isset($_SESSION['logged']) && $_SESSION['logged'] == 1) { $bLoggedIn = true; }
return $bLoggedIn;
}
function isLoggedIn() { if (isset($_SESSION['logged']) && $_SESSION['logged'] == 1) { return true; }
return false;
}
function isLoggedIn() { if (isset($_SESSION['logged']) && $_SESSION['logged'] == 1) return true; return false; }
-m
|
|
|
|