Set Session Expiration Time Manually-CodeIgniter

后端 未结 9 956
粉色の甜心
粉色の甜心 2021-01-01 10:23

How can I set session expiration time dynamically in codeigniter?

For example, if a user logs in and has the role of admin, the expiration time should b

9条回答
  •  庸人自扰
    2021-01-01 10:42

    In your login functionality just after user credentials have been verified you can check if user is admin and set different sessions accordingly. Something along these lines

    session->sess_expiration = 14400; // 4 Hours
    
    }else{
    
    // For ordinary users
    $this->session->sess_expiration = 1800; // 30 minutes 
       
    
    }
    $this->session->sess_expire_on_close = FALSE;

提交回复
热议问题