CodeIgniter supports flashdata data and it use to the next server request and then automatically cleared.
Add Flashdata
We can simply store flashdata as following.
$this->session->mark_as_flash('key');
mark_as_flash() function is use to takes only one argument of the value to be stored. You can also pass an array to store multiple values.
set_flashdata() function is use to takes two arguments, name and value, as shown below. You can also pass an array.
Or alternatively, using the set_flashdata() method:
$this->session->set_flashdata('key', 'value');
Retrieve Flashdata
However, if you want to be sure that you’re reading flashdata you can also use the flashdata() method:
$this->session->flashdata('key');
To get an array with all flashdata, simpl the key parameter :
$this->session->flashdata();
keep_flashdata() method use you can find flashdata variable through an additional request . You can either pass a single item or an array of flashdata items to keep.
$this->session->keep_flashdata('key'); $this->session->keep_flashdata(array('key1', 'key2', 'key3'));