CodeIgniter send and retrieve data using flash messages
How to send and get data by using flash messages in the codeigniter.This is simple and passing data using array.But if you reload/refresh the page, your data may not be displayed.Because data passing using flash message.However you can pass huge of data through this method.
$userDetails = array(); // declare the array $userDetails['id'] = 10; $userDetails['user_name'] = 'John'; $userDetails['amount'] = $250; //create flash message $this->session->set_flashdata('UserData', $userDetails);
You can get this details like this.
// get array $usersPaymentData = $this->session->flashdata('UserData'); // display details echo $usersPaymentData['id']; echo $usersPaymentData['user_name']; echo $usersPaymentData['amount']; // simply print_r($usersPaymentData);
Same way as simply,
In the controller.
$myArr = array('value 1', 'value 1'); $this->session->set_flashdata('myArray', $myArr);
View file
print_r($this->session->flashdata('myArray'));
If your flash messages are not working, then you must read this post.
Codeigniter flash message doesn’t work
What's your reaction?
Excited
0
Happy
0
In Love
0
Not Sure
0
Silly
0