How does CodeIgniter save session data even when you close your browser?

I wonder how the session works in CodeIgniter. Isn't a session considered automatically disconnected when you close your browser? CodeIgniter does not destroy the session in the default browser:

$config['sess_expire_on_close'] = FALSE; 

Instead, we can set the session end time:

 $config['sess_expiration'] = 7200; 

Now, for example, if I set the expiration time to 0, it will maintain the session until I destroy it myself:

 $this->session->sess_destroy(); 

So, how does CodeIgniter store session information for a certain amount of time, even after closing the browser?

In addition, is it safe to use this default option (non-expiring session with closing the browser) in order to maintain user registration for several days? (e.g. store in the session 'logged_in' => TRUE )

+4
source share
1 answer

A session in CodeIgniter does not use PHP $_SESSION by default. It uses its own implementation with cookies. That is why it is not destroyed when you close the browser. You can also use a database session in CodeIgniter with the option $config['sess_use_database'] = TRUE; and other things you will find here: http://codeigniter.com/user_guide/libraries/sessions.html

+3
source

All Articles