title: Yii::app()->user->isAdmin() is not working properly in layout page
body: <p>in my layout page Cmenu visible fn <code>Yii::app()-&gt;user-&gt;isAdmin()</code> is not working properly when i use <code>Yii::app()-&gt;user-&gt;isAdmin()</code> in someother  view it showing correct value but not working in layout.
  my code in protected/views/layouts/main.php</p>
  
  <pre><code>    &lt;?php $this-&gt;widget('zii.widgets.CMenu',array(
          'items'=&gt;array(
              array('label'=&gt;'Home', 'url'=&gt;array('/site/index'),/*'visible'=&gt;!Yii::app()-&gt;user-&gt;isGuest*/),
              array('label'=&gt;'Master','url'=&gt;array('/site/master'),'visible'=&gt;Yii::app()-&gt;user-&gt;isAdmin()),
              array('label'=&gt;'Transaction','url'=&gt;array('/site/transaction'),'visible'=&gt;Yii::app()-&gt;user-&gt;isAdmin()),
              array('label'=&gt;' Alotted Task','url'=&gt;array('/site/alottedtask'),'visible'=&gt;!Yii::app()-&gt;user-&gt;isGuest),    
              array('label'=&gt;'Completed Task','url'=&gt;array('/site/completedtask'),'visible'=&gt;!Yii::app()-&gt;user-&gt;isGuest),
              array('label'=&gt;'Status Update', 'url'=&gt;array('/site/statusupdate'),'visible'=&gt;Yii::app()-&gt;user-&gt;isAdmin()),
  
              array('label'=&gt;'Login', 'url'=&gt;array('/site/login'), 'visible'=&gt;Yii::app()-&gt;user-&gt;isGuest),
              array('label'=&gt;'Logout ('.Yii::app()-&gt;user-&gt;name.')', 'url'=&gt;array('/site/logout'), 'visible'=&gt;!Yii::app()-&gt;user-&gt;isGuest)
          ),
      )); ?&gt;
  </code></pre>
  
  <p>it showing the error like</p>
  
  <blockquote>
    <p>Trying to get property of non-object </p>
  </blockquote>
  
  <p><strong>Update:</strong></p>
  
  <p>My error page <code>http://localhost/tracktest/index.php</code></p>
  
  <p><img src="https://i.stack.imgur.com/DTwsU.png" alt="error page"></p>