Jump to content

What's wrong with this if statement? Simple test won't work..


virtuexru

Recommended Posts

I'm trying to create a rule, if a user is logged in, he see's this menu button. If he's not, he doesn't see it. I see it regardless or not if the user is logged in....

<?
  if (isset($_SESSION['image_is_logged_in']))
    {
      echo "<a href='main.php'>My Profile</a>";
    }
  else
    {
      echo "<a href='register.php'>Register</a>";
    }
?>

Should I be doing if($_SESSION['image_is_logged_in'] = true) {} else {} ?
When the user logs out what is the [b]$_SESSION['image_is_logged_in'][/b] variable set to.

ALso the following code does not check the value of the variable but the existance of it:
[code]if (isset($_SESSION['image_is_logged_in']))[/code]

You'll want to add an [b]and[/b] expression (&&) after the isset function to see if the variables value is true, like so:
[code=php:0]if (isset($_SESSION['image_is_logged_in']) && $_SESSION['image_is_logged_in'] == TRUE)[/code]

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.