Welcome Guest, Not a member yet? Register   Sign In
Cannot retive the session

I can store the session but i cannot retrieve it , if i try to retrieve , it is just null   .please help me  here i have attached my coding


class Login extends CI_Controller{

function index(){


function validation(){




'username' => $this->input->post('username'),
'log' => TRUE,


//echo $data->$username;



echo $log;//RESULT IS NULL
echo $h; // RESULT IS NULL



BUT I RETRIEVE ALL DATA like this it shows
like below
i can see that my session is stored
the output for  

$this->session->all_userdata(); ,
Array ( [session_id] => 2b9b1c3cadf7cd7ff49
c6b576244d2dc [ip_address] => ::1 [user_agent] => Mozilla/5.0 (Windows NT 6.1; WOW64; rv:35.0) Gecko/20100101 Firefox/35.0 [last_activity] => 1420380027 [user_data] => [0] => Array ( [username] => thamarai [log] => 1 ) )


echo $s;// it is working it shows some id , but the session which i'm storing like username, log. i cant retrieve it
Thanks and Regards,
Thamaraiselvam T

(This post was last modified: 01-04-2015, 10:12 AM by Mohammadhzp. Edit Reason: Typo )

$data[] = array(

'username' => $this->input->post('username'),
'log' => TRUE,

This is the issue
you can do this:
$data['username'] =  $this->input->post('username');
$data['log'] = TRUE;

then u can access it like this :
$name = $this->session->userdata('username');
$log = $this->session->userdata('log');

or u can do this :

'username' => $this->input->post('username'),
'log' => TRUE,
$user_info = $this->session->userdata('user_info');
$name = $user_info['username'];

and don't forget that session will be available on the next request(I mean you need to refresh page then display it,you can not display sessions right after seting it)

Theme © iAndrew 2016 - Forum software by © MyBB