在我的默认config.php中,所有用户会话都将根据提供的值
过期 $config['sess_expiration'] = 7200;
我有一个特定的用户,我需要将会话过期设置为与其他用户不同,比方说15分钟
这就是我试过的
SomeController
function __construct()
{
parent::__construct();
$this->load->model('store_manager/Storemanager_model');
$session_data = $this->session->userdata('logged_in');
$data['username'] = $session_data['username'];
$data = array(
'username' => $session_data['username'],
);
$this->session->sess_expiration = '300';// expires in 15 minutes
$this->session->set_userdata($data);// set session
}
不起作用,返回空白页
更新
我修改此代码添加一些条件
function __construct()
{
parent::__construct();
$this->load->model('store_manager/Storemanager_model');
if($this->session->userdata('logged_in')) {
$session_data = $this->session->userdata('logged_in');
$user = $session_data['username'];
if ($user == 'retailer_1')
{
//set session to non-expiring
$this->session->sess_expiration = '32140800'; //~ one year
// $this->session->sess_expire_on_close = 'false';
}
}
}
仍然有空白页