A way to store flash messages besides CwebUser

The current way stores the flash messages in the CWebUser lib which is erased when being logged out as it seems. So if I want to store a flash message like “you have been successfully logged out” and redirect the user to the logout page the message is erased during logout so my question is…wouldn’t it make more sense to keep the flash messages outside that class and make it available no matter what action is being performed regarding user? Or is there another way of storing flash messages that I’m missing?

In Web3CMS I did following:


     * Logout the current user and redirect to homepage.


    public function actionLogout()



        $screenName=$isLoggedIn ? Yii::app()->user->screenName : '';

        // log user out and destroy all session data


        // if user was logged in, we should notify of being logged out




                // have to re-open session destroyed on logout. this is necessary for user flash


            // set the goodbye message


                '{screenName}, you have been successfully logged out.',




        // go to home page



so, you have to open the session again before assigning a flash message Yii::app()->getSession()->open();

You may use Yii::app()->user->logout(false), i.e., do not destroy session when logout.

That worked. Thanks.

Hmm, I still can’t get it to work. I want to do the exact same thing.

public function actionLogout() {


Yii::app()->user->setFlash('flashMsg', 'You have been logged out.');