View Single Post
Old 07-03-2008, 09:06 PM   #5 (permalink)
delayedinsanity
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

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
delayedinsanity is offline  
Reply With Quote
The Following User Says Thank You to delayedinsanity For This Useful Post:
codefreek (07-03-2008)