title: PHP Class variable question
body: <p>I have the following class which handles my user logged in / logged out (I only included what's relevant here). I want to redirect users who are logged in who visit login.php to there account page. I do this using....</p>
  
  <pre><code>    $User = new User();
  if ($User-&gt;loggedin = 'true') header('Location:MyAccountNEW.php');
  </code></pre>
  
  <p>The issue is this redirects to myaccountnew.php weather I switch it to true or false.. (although it does not when the condition is (2>3). Aslo when I echo $User-loggedin, nothing comes up. I'm kinda stumped...</p>
  
  <p>Heres the class</p>
  
  <pre><code>Class User {
  
  public $loggedin = false;
  public $username = "";
  public $ShopperID = "";
  
  function __construct() {
      $this-&gt;CheckLogin();
  }
  
  function CheckLogin() {
      if (!empty($_SESSION['LoggedIn']) &amp;&amp; !empty($_SESSION['Username'])) {
              $this-&gt;loggedin = true;
              $this-&gt;username = $_SESSION['Username'];
      }
      else {
          $this-&gt;loggedin = false;
      }
  }
  </code></pre>
  
  <p>heres what logout.php looks like</p>
  
  <pre><code>&lt;?php include ("base.php");
    include("userclass.php");
  
    $User = new User();
    $User-&gt;loggedin = false;
  </code></pre>
  
  <p>$_SESSION = array(); session_destroy(); ?>
  </p>