I'm trying to save my session, it expired after refreshing the page.
In my controller:
if($u_id){
$data= array(
'id'=>$u_id['id'],
'user_name'=>$u_id['user_name'],
'password'=>$password,
);
$this->session->set_userdata('logged_in',$data);
$this->session->set_flashdata('login_succeed','Logged in Successfully');
redirect('home/homepage');
}
And in my homepage view:
if (isset($this->session->userdata['logged_in'])){
echo $this->session->userdata['logged_in']['user_name'];}
My config:
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = NULL;
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
First time when redirect me to homepage, the session is correct and it gave me the username perfectly, but when I refresh the page, the session expired and redirect me to login page. Should I do something in construct or what can I do? please help! I'm using codeigniter