Why codeigniter session expires frequently ? also

2019-06-07 23:01发布

问题:

I'm using codeigniter for my app. development.

These are the session settings. I'm using DB session.

$config['sess_cookie_name']= 'ci_session';
$config['sess_expiration']= 7200;
$config['sess_encrypt_cookie']  = FALSE;
$config['sess_use_database']    = TRUE;
$config['sess_table_name']= 'ci_sessions';
$config['sess_match_ip']= FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update']  = 300;

I am not using AJAX or dynamic resources loading the session library. Also I have checked session data,all data are saving in DB.

This is working well on localhost.

回答1:

By default it's expire every 2 hours (7200) but check if in your app destroy session in some cases. If you want to increase the hours wirte a bigger number than 7200 in $config['sess_expiration']. Example:

$config['sess_expiration']= 18000; //5 hours

If you want that the session doesn't expire write:

$config['sess_expiration']= 0;