I've been using CodeIgniter for a while now and never put second thoughts to this but the other day I came across an issue which may cause a few to trip over.
The standard practice in CodeIgniter when posting forms is to set the flashdata in the controller and redirect to the same page, or a confirmation / failure screen, and show the flash data using
$this->session->flashdata('item');
Easy. Once you set the flashdata it stays in the session until the page is reloaded, gets shown on the next page load then disappears into the electronic ether.
There is one catch though. What happens if you don't want to, or more importantly can't, reload the page? Well there is a way to get the flash data although it's not recommended. It's going against the intended functionality and you might be better off passing your own variables. If you're happy for some potential for CodeIgniter to bite back then read on.
To fully understand how to solve the problem we need to understand how the flash data works so we need to dig a little deeper. In short the flashdata is nothing more than a glorified userdata variable stored in the session. When you add something to the flashdata you get this:
$this->session->userdata('flash:new:some_name');
When the page is reloaded the flash:new variables get shown then marked as flash:old and on the next page load all flash:old variables are wiped away. This is our way in to get the data without reloading the page. Simply call the above line to get your flash data message that you put in e.g. in your view.
As I said you will run into pitfalls. Where you have one form which on save, redirects to another page and a different form which stays on the same page when posted. Both very different scenarios on the same site or application but both very possible. If implemented properly though it can be very useful.