Checking Yii::app()->User->Isguest From Template

I have a master template in:


and I’m trying to show a “Logout” button if a user is logged in. However, from the template code (main.php)


is returning true even if the user is logged in.

Having said that, in my module’s view (protected/modules/mymodule/views/query/view.php), the same


returns false. Why isn’t the template picking it up and what do I need to do to make it so?

Thanks in advance.

Your code look correct. Try using the function instead:


That function will return if the current user is guest (not authenticated).

Yii::app()->user is documented here: CWebUser

Please show the specific code you are using for generating the Logout button.