First of all I should remind you I have read this question , I am using Codeigniter 3 . I want to destroy session with browser closing like PHP session ! I have read somethings about using ajax like this :
var unloadHandler = function(e){
//here ajax request to close session
};
window.unload = unloadHandler;
and ....
But I dont want to make myself dependent to js for destroy session with browser closing .
this is my config.php
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'soheil_blog_name';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = NULL;
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
You just have to set 'sess_expiration' to 0, as described in the manual and in the config.php comments.
Note: Technically, you can't really destroy the session when the browser is closed. You can only tell the browser to discard the session cookie after it is closed, but the session itself is still usable on the server-side (i.e. if you are the victim of a MITM attack and somebody stole the session ID).
The session is actually deleted later by the garbage collector.