How to close session when browser is closed, in CodeIgniter?

We are building a small app for a non-lucrative, and we are using sessions on it – who doesn’t use it? -.
We need that when some user closes the browser the session must be destroyed.

This is how its done.

Open the geral config file application/config/config.php, search for $config[‘sess_expiration’]

$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_expire_on_close']	= FALSE;
$config['sess_encrypt_cookie']	= FALSE;
$config['sess_use_database']	= FALSE;

Change 7200 for -1. You should got something like

$config['sess_expiration'] = -1;

That should do the work! đŸ™‚

One thought on “How to close session when browser is closed, in CodeIgniter?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.