It may be well known to some people how to kill sessions on browser close but the default config in codeigniter doesn’t provide so. In lot of application which has admin interface, we don’t want browser to store the session. So it needs to kill the session when browser is closed. Example behavior can be found in yahoo email page.
So how do we do that in Codeigniter ? It’s simple, although this feature is not well commented or documented. Ok, now open system/application/config/config.php file
And find the settings called $config[‘sess_expiration’] under the section Session Variables and put the value like this
$config['sess_expiration'] = -1;
That’s it. Now your session will be killed in the event of browser closing.