Access Session data in codeigniter

 $username = $this->input->post('username');
$password = $this->input->post('password');
$result = $this->AccountModel->login($username,$password);
foreach($result as $row){
$loggedin = array('Admin_name' => $row['username'], 'is_loggedin' => TRUE);

How would i be able to access ['Admin_name'] and ['is_loggedin'] without having to run this code and running a foreach loop $this->session->all_userdata()


From "Retrieving Session Data" section of Session Class docs:

Any piece of information from the session array is available using the following function:


So you want:


The docs are your friend ;)

try this


You can access as below:

$Admin_name = $this->session->userdata('Admin_name');

For session library, please check the CI User guide on sessions

u can access it by using this line


it should work ..if it dosen't ..just print the session variables using any of the line below

echo '<pre>';print_r($this->session->all_userdata());exit;
echo '<pre>';var_dump($this->session->all_userdata());exit;

once u see the structure of userdata ..u can easily access any session variables in there just like any other array ..just use


Need Your Help

Storing object pointers efficiently for game c++

class pointers vector

I'm making a hooked modding code for GTA San Andreas. The game has its own classes, one of them is class CPed. It handles the attributes of random pedestrians created by the game, which is huge in

SQL - How do I search for "weight" within CONTAINS?

sql contains

We have a full-text index setup to allow searching a directory for PDF files containing specified text. I've been getting notifications that's it's blowing up when people are searching for "weight ...