I am facing problems in codeigniter 2.x session class. I want to have userid in session for global access on my pages after user login
I have 2 views and 1 controller
one view one i had a login form when a user submits the form
i validate it and create session user data by calling a method within controller as
function create_session($data) {
$mydata = array(
'userid' => $data,
'role' => $role,
'logged_in' => TRUE
);
$this->session->set_userdata($mydata);
return;
}
then my 2nd view is loaded
and i have on that view
print_r($this->session->userdata);
and it print out the right results
but when i click on 1st view in navigation
i fond that
[userdata] =>
its empty
my session configuration is as
$config['encryption_key'] = 'askdfjowieuriomzx,mv';
$config['sess_cookie_name'] = 'wana_session';
$config['sess_expiration'] = 7200;
$config['sess_expire_on_close'] = FALSE;
$config['sess_encrypt_cookie'] = TRUE;
$config['sess_use_database'] = TRUE;
$config['sess_table_name'] = 'wana_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update'] = 300;
I have searched the forums, but i can’t solve this problem
please solve this issue or suggest an alternative method.
Try changing the reference to ‘gmt’ – in
config.php$config['time_reference'] = 'gmt';instead of$config['time_reference'] = 'local';