$this->session->set_flashdata() and then $this->session->flashdata() doesn't work in codeigniter $this->session->set_flashdata() and then $this->session->flashdata() doesn't work in codeigniter codeigniter codeigniter

$this->session->set_flashdata() and then $this->session->flashdata() doesn't work in codeigniter


Well, the documentation does actually state that

CodeIgniter supports "flashdata", or session data that will only be available for the next server request, and are then automatically cleared.

as the very first thing, which obviusly means that you need to do a new server request.A redirect, a refresh, a link or some other mean to send the user to the next request.

Why use flashdata if you are using it in the same request, anyway? You'd might as well not use flashdata or use a regular session.


// Set flash data $this->session->set_flashdata('message_name', 'This is my message');// After that you need to used redirect function instead of load view such as redirect("admin/signup");// Get Flash data on view $this->session->flashdata('message_name');


To set flashdata you need to redirect controller function

$this->session->set_flashdata('message_name', 'This is test message');//redirect to some functionredirect("controller/function_name");//echo in view or controller$this->session->flashdata('message_name');