I am using Codeigniter 2.1.4 and I have facing some issues with flashdata.
When I successfully submit record I can display the flashdata message. But if go to the other page from the page where flashdata message was displayed and then go back to previous page using browser back button it shows me flashdata message again.
How to clear flashdata message once it used?
I think its not the flashdata issue its cache problem. I am confused why this is happening. If its cache issue then how to remove it?
Below is code I have used,
//In the manage of controller
$this->session->set_flashdata('message', "Record updated successfully.");
// In the view of controller
$data['message'] = $this->session->flashdata('message');
// In the view page
echo $message;
Flash disappears only after next refresh
your code in controller is right
//In the manage of controller
$this->session->set_flashdata('message', "Record updated successfully.");
redirect('controller_name/function_name','refresh');
now in view use like this
if($this->session->flashdata('message')){echo $this->session->flashdata('message');}
hope it will work
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With