Reputation: 30431
Ok, I know what I'm about to say is going to be super vague, but hear me out:
I want to use flash messages because I like the idea of them, but they don't seem to always work for me.
Here is my workflow:
The problem is after I redirect the user, the flash messages are no longer in the $_SESSION. To make this even more strange, if I take out the step where I send email notifications, it DOES work. WTF?
Has anyone else experienced similar issues with flash messages? Does anyone have any insight into why sending the email would affect the flash messages?
I think at this point I'm just going to stick with setState and manually remove it after displaying them.
Upvotes: 0
Views: 2671
Reputation: 31
Now You can set a property autoUpdateFlash of CWebUser component to false. In this case flash message will be removed only after usage.
Upvotes: 3
Reputation: 15600
How is the email being sent? I know using the Yii Mail extension (a swiftmailer wrapper I think) in "debug" mode uses the setFlash method, so perhaps that's wiping out the array somehow...?
The "flash" variables are updated by the init() method of CWebUser, so if there is an extra call to CWebUser it's possible that's what is clearing out the flash variables.
Considering that you set the flash AFTER the email though, I'm not sure how that would happen. My only other guess besides the "debug mode" thing (not a problem if you are just using the PHP mail methods though) is that sending mail is triggering an extra redirect somewhere.
If you have a PHP debugger like XDebug installed I would set a breakpoint in the getFlash and setFlash code and get a look at what is happening that way.
Good luck!
Upvotes: 1