I have tried the following but it is giving me errors:
print_r($this->session->userdata());
How can I show all session data in CodeIgniter?
To get all users session data. First we need to initialize the Session class manually in our controller constructor use following code. $this->load->library('session');
php session_start(); echo "<h3> PHP List All Session Variables</h3>"; foreach ($_SESSION as $key=>$val) echo $key." ".
Use this: echo '<pre>'; var_dump($_SESSION); echo '</pre>'; Or you can use print_r if you don't care about types.
If you want to print the full array, as a string, try print_r($array); .
print_r($this->session->userdata);
or
print_r($this->session->all_userdata());
Update:
As of version 3.1.11 the above methods are deprecated. Use the below method to get all session data,
print_r($this->session->userdata());
echo "<pre>"; print_r($this->session->all_userdata()); echo "</pre>";
Display yet formatting then you can view properly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With