title: Pass variable from controller to layout in CakePHP
body: <p>My variable <code>loggedIn</code> is defined in my <code>AppController</code>  in the <code>beforeFilter()</code> function, as follows:</p>
  
  <pre><code>function beforeFilter(){
          $this-&gt;Auth-&gt;loginRedirect = array('controller'=&gt; 'questions', 'action' =&gt; 'home');
          $this-&gt;Auth-&gt;logoutRedirect = array('controller'=&gt; 'questions', 'action' =&gt; 'home');
          $this-&gt;Auth-&gt;allow('signup', 'confirm', 'home', 'show');
          $this-&gt;Auth-&gt;authorize = 'controller';
          $this-&gt;Auth-&gt;userScope = array('User.confirmed' =&gt; '1');
          $this-&gt;set('loggedIn', $this-&gt;Auth-&gt;user('id'));
      }
  </code></pre>
  
  <p>In my layout, I am testing the value of the <code>loggedIn</code> variable using the following: </p>
  
  <pre><code>&lt;?php if($loggedIn): ?&gt;
  </code></pre>
  
  <p>When I run the application I get this error: </p>
  
  <pre><code>Undefined variable: loggedIn [APP\View\Layouts\default.ctp
  </code></pre>
  
  <p>Can you help me? Thank you in advance. </p>