问题
I have set the flash data like this
$this->session->set_flashdata('dispMessage','my message is here'));
I found that message in session library but not display in redirect page. and I am use the codeigniter version 2.2.0.
Can anyone help...?
回答1:
According to the session class page of the manual:
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").
Try preserving the flashdata in your script immediately prior to redirecting as follows:
$this->session->keep_flashdata('dispMessage');
回答2:
// Set flash data
$this->session->set_flashdata('dispMessage', 'This is my message');
// After that you need to used redirect function instead of load view such as
redirect("yourcontroller/controllermethod");
// Get Flash data on view
$this->session->flashdata('dispMessage');
来源:https://stackoverflow.com/questions/31115835/codeigniter-flashdata-not-working-after-redirect