CodeIgniter Forums
Session expire - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17)
+--- Thread: Session expire (/showthread.php?tid=64305)



Session expire - spyrosjevan - 02-05-2016

Hello there guys, im having a basic problem with the session expire

What im intent to do is when the session expires auto logout the user.

This is the code for the login page which sets the session.
PHP Code:
$result $this->db->query("SELECT * FROM rulers WHERE username = '".$username."' AND password = '".$pass."'");
        
$row $result->row();

        
$time $this->session->sess_expiration 10;
        
$userdata = array(
            
'user_id'                  =>$row->id,
            
'username'              =>$row->username,
            
'time'                    =>$time,
            
'Administration_login'    => true
        
);
        
        
$this->session->set_userdata($userdata); 

And this is the check code

PHP Code:
$login $this->session->get_userdata('time');
        
 
       if($login == 0){
 
           $this->session->sess_destroy();
 
           redirect('Administration/Login','Location');
 
       



RE: Session expire - Narf - 02-05-2016

You can't set sess_expiration like that ... It has to be in the config file.


RE: Session expire - spyrosjevan - 02-12-2016

(02-05-2016, 11:23 AM)Narf Wrote: You can't set sess_expiration like that ... It has to be in the config file.

thanks