I have problem with sessions in CodeIgniter. When user log in to system I have this code:
$data_login = array(
'id' => $user->id,
'name' => $user->name,
'email' => $user->email,
'logged_in' => true
);
$this->session->set_userdata($data_login);
My sessions config:
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = sys_get_temp_dir();
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
In general, everything works but when I do not log out and close the page tab, then I will visit the site again $this->session->userdata('logged_in') returns NULL. When I enter another subpage, everything returns to normal - recognizes the logged in user.
Where is problem? :/
@edit:
Here is my cookie config:
$config['cookie_prefix'] = '';
$config['cookie_domain'] = '';
$config['cookie_path'] = '/';
$config['cookie_secure'] = FALSE;
$config['cookie_httponly'] = FALSE;
@edit2:
I noticed that this happened on the new hosting. Everything works on old hosting.
session_start
being called when the framework is bootstrapped. – Script47