I have the following code:
<?php
if (!$this->Auth->user())
{
echo $this->element('header');
}
else
{
echo $this->element('header-bar');
}
?>
inside my view which should show a different header for logged in users but throws the following error:
Notice (8): Undefined property: View::$Auth [APP/views/layouts/page.ctp, line 17]
Fatal error: Call to a member function user() on a non-object in /Users/cameron/Sites/thehive/app/views/layouts/page.ctp on line 17
How do I fix this? Thanks
You don't need to do $this->set(compact('authUser'));
only use this in View:
if ($this->Session->read('Auth.User')){
// do something
}