views:

374

answers:

2

Instead of doing the following:

print $this->session->userdata('username');
print $this->session->userdata('email');
print $this->session->userdata('phone');
print $this->session->userdata('fax');
//etc...

Is there a way to do something like

foreach($this->session as $key=>$val) print $key.'-'.$val;

Or is it possible to do something like

print_r($this->session);

The reason I'm asking is because I don't know what the SESSION keys are and I also want to be able to loop through CI Session values.

A: 

You can do

print_r($this->session);

It will return an array of all your sessions.

Thorpe Obazee
+1  A: 

$this->session is an object of course,and you can dump it using print_r or var_dump

but i recommend using this for fetching all of your session data except for flash data:

$sessionArray = $this->session->all_userdata();

cubny

related questions