Q:

Yii setFlash with Logout

Im tying to use the command sequence:
Yii::app()->user->setFlash('success', "Successful!"); 
Yii::app()->user->logout();
$this->redirect(array('user/login'));

The user got logged out and redirected, but the Setflash does not work. 
I also tried to change the order of 2 frist commands, but got the same problem. 
If I do not logout the user, the Setflash works fine. 
How can I make both commands work? 

A:

this should work
Yii::app()->user->logout();
Yii::app()->session->open();
Yii::app()->user->setFlash(...);

If you need to destroy a whole session but you want to set a flash afterwards, you may extends CWebUser this way:
<? php

class BaseWebUser extends CWebUser
{

        public function logout($destroySession = true)
        {
                parent::logout($destroySession);
                Yii::app()->session->open();
        }

}

? >

have a closer look here

A:

Flash messages are stored in the session.  Logging the user our destroys the user's current session.  Once session_destroy() is called, you must call session_start() again in order to generate a new session ID and have this work.  Yii most likely does not do that. 
If it's that important that you have a "Successful" message indicating that the logout worked - then redirect the user to a "logout successful" page.  Alternatively, you can look into overriding the way Yii performs a logout - although I wouldn't recommend it.