Reputation: 701
My web application(Codeigniter) will have flash message done by PHP session flash.
But currently I found that the flash message appear again when pressing the back button of the browser.
I want to clear the flash once it is shown. How can I do that?
This is how I save the flash message:
$ci->session->set_flashdata('flash', $flash);
and get it from my view
$flash = $this->session->flashdata('flash');
Upvotes: 1
Views: 1382
Reputation: 1280
Flash message should hide after page refresh. When you click back button of browser some times the page is not refreshed, so the flash message will be shown again.
Upvotes: 3
Reputation: 928
Once you show your flash message clear that session at that point only ($this->session->clear('flashdata')).
If you require it again you can set same session variable from controller. I do same for error and success messages.
*Just clear you session right after you 'echo' it on your view page.
Upvotes: 0