Logout User In Component/cpntroller

Hello guys

I want to logout user everywhere in my site when my condition satisfy. The best way, is to put my code in base controller class which will execute first of all I think. My code is:



	$user = User::model()->findByAttributes(array(), 'id=:id AND username=:username', array(

		':id' => Yii::app()->user->id,

		':username' => Yii::app()->user->username,


	if($user === NULL)





But when it want to excute $this->redirect it can’t connect to logout action, what I can do?

Any help will be appreciated, thanx in advance

Instead of


I put this:


simply add into your config main.php file -



	   // enable cookie-based authentication


	   'autoRenewCookie' => true,

           'authTimeout' => 86400, //kills session after 24 hours just in case above fails or if a user clicks remember me it will only last for this duration.

           'loginUrl' => array('site/login'),