Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Codeigniter - get all users session data

I need to get all sessions data and take some actions upon them, is there any possible way to get them, I found how to solve it in php but codeigniter use's it own custom sessions library.

Native php

$_SESSION

How can I do it in codeigniter

like image 957
Sabri Aziri Avatar asked Mar 03 '14 14:03

Sabri Aziri


2 Answers

To get all session data you can use $this->session->all_userdata();

To print all your session variable use this line anywhere in your code :

echo '<pre>'; print_r($this->session->all_userdata());exit;
like image 140
Mohan Avatar answered Oct 22 '22 08:10

Mohan


You can use db session. So data will be stored to the database. See Saving Session Data to a Database

If you have no database support just use cookie and get the data with

$username = 'John Doe';
$this->session->set_userdata('username',$username);
$var = $this->session->userdata;
echo $var['username'];
like image 33
stavgian Avatar answered Oct 22 '22 10:10

stavgian