ManInTheBox
(Stankovic Zarko)
January 13, 2012, 5:37pm
1
Hello,
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?
Thanks
andy_s
(Arekandrei)
January 13, 2012, 6:05pm
2
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.
ManInTheBox
(Stankovic Zarko)
January 14, 2012, 11:08pm
3
andy_s:
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.
requestS
I see here plural which means not only on the next page .
Right?
Perhaps it’s typo in documentation…
andy_s
(Arekandrei)
January 15, 2012, 8:39am
4
ManInTheBox:
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.
requestS
I see here plural which means not only on the next page .
Right?
Perhaps it’s typo in documentation…
(current + next) requests.
ManInTheBox
(Stankovic Zarko)
January 15, 2012, 4:56pm
5
Thanks andy_s, now it’s clearer explanation.