Welcome Guest, Not a member yet? Register   Sign In
Does flashdata resist a "redirect"=
#1

[eluser]pabloheim[/eluser]
hi, i have a basic quesiton ,

imagine within a controller i set something like this:

Code:
if (!something){

$this->session->set_flashdata('item', 'value');
redirect('home','location');
}
will i be able to use the value of the item set in the flashdata in the redirected controller?

thanks!
#2

[eluser]InsiteFX[/eluser]
Flashdata
CodeIgniter supports "flashdata", or session data that will only be available for the next server request, and are then automatically cleared. These can be very useful, and are typically used for informational or status messages (for example: "record 2 deleted").

From the CodeIgniter users guide:

Note: Flash variables are prefaced with "flash_" so avoid this prefix in your own session names.

To add flashdata:

Code:
$this->session->set_flashdata('item', 'value');

You can also pass an array to set_flashdata(), in the same manner as set_userdata().

To read a flashdata variable:

Code:
$this->session->flashdata('item');

If you find that you need to preserve a flashdata variable through an additional request, you can do so using the keep_flashdata() function.

Code:
$this->session->keep_flashdata('item');

Enjoy
InsiteFX
#3

[eluser]Aken[/eluser]
Short answer: yes.




Theme © iAndrew 2016 - Forum software by © MyBB