CodeIgniter Forums

Full Version: CI3 Session Not Expiring On Browser Close
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi guys,

Using Codeigniter 3.1.2.

Below are my config details for session.

PHP Code:
$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 0;
$config['sess_save_path'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 7200;
$config['sess_regenerate_destroy'] = FALSE

I am told that upon setting the sess_expiration to 0 that it would be destroyed upon browser close.

However, this does not seem to happen.

Any idea?
Any method I can use to utilise this?

Using javascript seems not practical since it gets triggered when used the back button and when going to a different URL.
It is possible if you change the sess_time_to_update with 1 day (means session destroy after 24 hour)
I need the session to be destroyed when the user closes the browser
You can try this but make sure you clear your browsers cache before testing it again.

ini_set('session.cookie_lifetime', 0);
Thank you for the reply.

I added your code to the constructor of the of the default controller.

PHP Code:
public function __construct()

But it still seems to have no effect.
Any idea why?