CodeIgniter supports "flash data", or session data is only available for the next server request and is automatically cleared. This should be useful and often applied to information or status hints (for example: "Record 2 deleted").
For example, when a record is deleted from the article List page, "Record 2 deleted" is prompted. or edit the article when you save the prompt "article modify success" or "Modify failed, parameter error" and so on.
Key techniques in the code: in the session key value pairs, the key name added "new" or "old" to judge
Set_flashdata (when setting the Flash data, plus new, which indicates the fresh flash data)
$flashdata _key = $this->flashdata_key. ': New: ' $key; $this->set_userdata ($flashdata _key, $val);
Flashdata (when it gets, it's old data)
$flashdata _key = $this->flashdata_key. ': o LD: '. $key; return $this->userdata ($flashdata _key);
The 2-step operation (in the constructor) was done before getting it:
1. _flashdata_sweep () function: Delete all old data
2, _flashdata_mark () role: Replace the new data with old data
So the 1th time Flashdata can fetch old data.
If the 2nd time is acquired again, because the _flashdata_sweep () function deleted old, so no more data can be obtained.
Session flash data Flash in CI framework