I have a PHP function I'm using to determine if my user is logged in or not, it's very simple, and the code by itself works. I've never used functions much before, but I want to start. So I have my function is_logged(), which returns true if the user is logged in, obviously false if not. But when using the function, it is always returning true, no matter the circumstance. If I take the code within the function, and plainly have it outside of a function, it works, but if I put it back in the function, even if the user is logged out, it returns true.
is_logged Function
function is_logged(){
if(!empty($_SESSION["user"])){
return true;
} else {
return false;
}
}
How I'm trying to test the function.
if(is_logged) { echo "<br />Logged In"; } else { echo "<br />Not Logged In"; }
But the function only works if I take the inner code out of the function...I'm very confused as to why it's not working. The function is listed in a spot where the session variables can be read.
is_logged()it is a function call