Session that can be use only once
CodeIgniter supports “flashdata”, or session data that will only be available for the next request, and is then automatically cleared.
This can be very useful, especially for one-time informational, error or status messages (for example: “Record 2 deleted”).
It should be noted that flashdata variables are regular session vars, only marked in a specific way under the ‘__ci_vars’ key (please don’t touch that one, you’ve been warned).
To mark an existing item as “flashdata”:
$this->session->mark_as_flash('item');
If you want to mark multiple items as flashdata, simply pass the keys as an array:
$this->session->mark_as_flash(array('item', 'item2'));
To add flashdata:
$_SESSION['item'] = 'value'; $this->session->mark_as_flash('item');
Or alternatively, using the set_flashdata()
method:
$this->session->set_flashdata('item', 'value');
You can also pass an array toset_flashdata()
, in the same manner as set_userdata()
.
Tagged:
0
Howdy, Stranger!
Categories
- 94 All Categories
- 20 VoIP
- 7 SIP
- 16 asterisk
- 44 Programming
- 1 Nodejs
- 4 javascript
- 19 PHP
- 8 Codeigniter
- 14 database
- 1 UI/UX
- 2 Flutter
- 28 OS
- 26 Linux
- 1 Virtualization
- 1 Android
- 1 Windows
- 2 legal