我遇到了有关CodeIgniter超时的问题。
我知道可以通过配置文件夹手动设置会话超时时间,例如:
$config['sess_expiration'] = 123;
我需要网站管理员能够动态管理管理页面的会话超时时间。
请帮助我实现这个逻辑。
我尝试过这个逻辑但是不起作用。
$this->session->sess_expiration = "120";
注意:我在值中存储数据库。根据数据库的值,我可以设置会话过期时间。
注意1:
$config ['sess_time_to_update'] = 30;
此值小于会话过期时间。总逻辑代码:
public function edit($id)
{
Assets::add_css('../plugins/forms/uniform/uniform.default.css');
Assets::add_css('../plugins/forms/select/select2.css');
Assets::add_css('../plugins/forms/validate/validate.css');
Assets::add_css('../plugins/misc/qtip/jquery.qtip.css');
Assets::add_js('../plugins/charts/sparkline/jquery.sparkline.min.js');
Assets::add_js('../plugins/forms/uniform/jquery.uniform.min.js');
Assets::add_js('../plugins/forms/select/select2.min.js');
Assets::add_js('../plugins/forms/validate/jquery.validate.min.js');
Assets::add_js('../plugins/forms/wizard/jquery.bbq.js');
Assets::add_js('../plugins/forms/wizard/jquery.form.js');
Assets::add_js('../plugins/forms/wizard/jquery.form.wizard.js');
Assets::add_module_js('setting','setting');
if ($_POST)
{
$current_date = date("Y-m-d H:i:s");
$data = array(
's_meta_value' => $this->input->post('s_meta_value'),
'updated_on' => $current_date
);
$this->setting_model->session_mng_update($data,$id);
$session_val= $this->input->post('s_meta_value');
if($session_val == 0)
{
$this->session->sess_expiration = '0';
}
else
{
$this->session->sess_expiration = "120";
// $val1 = $this->config->item('sess_expiration');
// print_r($val1);
//$session_seconds = ($session_val*60);
$val2 = $this->config->set_item('sess_expiration',50);
$this->session->CI_Session();
//$val1= $this->config->set_item('sess_expiration',50);
$val3 = $this->config->item('sess_expiration');
print_r($val3);exit;
}
Template::redirect('setting/setting/display');
}
$val3 = $this->config->item('sess_expiration');
print_r($val3);exit;
$data = $this->setting_model->session_mng_edit($id);
Template::set('page_title', 'Edit Session Management');
Template::set('data', $data);
Template::set_view('setting/session_management/edit_session_management');
Template::render();
}