Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Showing all session data at once?

Tags:

codeigniter

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?

like image 775
Simpanoz Avatar asked Mar 03 '11 01:03

Simpanoz


People also ask

How do I get all session data in CI?

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');

How can I see all sessions in php?

php session_start(); echo "<h3> PHP List All Session Variables</h3>"; foreach ($_SESSION as $key=>$val) echo $key." ".

How would you print all of the variables being used in the session?

Use this: echo '<pre>'; var_dump($_SESSION); echo '</pre>'; Or you can use print_r if you don't care about types.

How do I print a session array?

If you want to print the full array, as a string, try print_r($array); .


2 Answers

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()); 
like image 157
Paulraj Avatar answered Sep 17 '22 01:09

Paulraj


echo "<pre>"; print_r($this->session->all_userdata()); echo "</pre>"; 

Display yet formatting then you can view properly.

like image 40
Ravi Chauhan Avatar answered Sep 21 '22 01:09

Ravi Chauhan