CodeIgniter Forums
Session expire on closing browser and time limit - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Session expire on closing browser and time limit (/showthread.php?tid=77601)



Session expire on closing browser and time limit - Lambchop - 09-23-2020

Hello. new here,

I am using CI 3, PHP 5.6.
I am making a basic user login with session.
I want to have a strict login with session expire in 20 minutes, and if browser close then destroy user session.

I know can set $config['sess_expiration'] = 0 to set destroy session on browser close and expire session in 20 minutes by setting $config['sess_expiration'] to 1200,
but I can't do both at the same time.
for now, i set a last active variable on session and sess_expiration to 0, and time out if last action is not in the 20 minutes time frame.
Is there anyway to do this?

Code:
$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = ??0 or 1200??;
$config['sess_save_path'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;