title: How to pass a logged in value between classes?
body: <p>I have a user class which has a structure like this</p>
  
  <pre><code>class User
  {
  
      private $_data, $_isLoggedIn;
  
      public function __construct()
      {
          //Initialising variables
      }
  
      public function login()
      {
          //logs in the user and assigns the value true to $_isLoggedIn i.e $this-&gt;_isLoggedIn = true
      }
  
      public function isLoggedIn()
      {
          return $this-&gt;_isLoggedIn;
      }
  
  }
  </code></pre>
  
  <p>What I want to be able to do is use the <code>isLoggedIn</code> value to check if a user is loggedIn inside another class to check if the user is logged in. So what I have done is like this</p>
  
  <pre><code>class Oranges
  {
      public function write()
      {
          $user = new User;
          if($user-&gt;isLogedIn) echo 'Logged In';
      }
  }
  </code></pre>
  
  <p>But every time I call the Oranges class I lose the value of <code>_isLoggedIn</code>.</p>
  
  <p><strong>How can I be able to check if the user is logged in without using sessions which I am told are not secure.</strong></p>