You can override or set a configuration item dynamically . If you just look at $config['sess_expire_on_close'] = TRUE; Whether to automatically terminate the session when the browser window is closed.
Set to true if the user has not checked the Remember Me box. And the session will expire after closing the browser.
And if he checks the Remember Me checkbox, set $ config ['sess_expire_on_close'] to FALSE, for example
if($this->input->post('remember')) $this->config->set_item('sess_expire_on_close', '0');
now the session does not expire after closing the browser. Note: this solution is also tested on Opera, Mozilla, Chrome and ie9
source share