Lost flash messages


I have one issue with flash messages.

// controller

public function actionTest()


    Yii::app()->user->setFlash('info', 'Some flash message');


When this action is invoked everything is ok. In $_SESSION array this message exists.

But when another request is made after this test page (move to another page), flash message is removed from $_SESSION!

Note that I didn’t call Yii::app()->user->getFlash(‘info’); but flash message is still gone.

According to the documentation it says that A flash message is available only in the current and the next requests.

I expected that message will be available until I call getFlash() but that’s not the case. It’s removed after another action is invoked.

Maybe solution is to disable autoUpdateFlash and manually remove messages after usage?

Is this a bug, or desired functionality?


It’s not a bug. Flash messages are supposed to be used only on the next page. For example, when you create/update/delete something you usually redirect a user to some page and show a flash message there.

Still, you can set autoUpdateFlash to false.

Thanks for reply.

I used flash messages many times before, so please don’t write its usage.

Problem here is documentation:

A flash message is available only in the current and the next requests.


I see here plural which means not only on the next page.


Perhaps it’s typo in documentation…

(current + next) requests.

Thanks andy_s, now it’s clearer explanation.