CodeIgniter Forums
Destroyed session with closed browser - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Destroyed session with closed browser (/thread-29674.html)



Destroyed session with closed browser - El Forum - 04-17-2010

[eluser]babazumbula[/eluser]
Hi,
I made Login application,and loguot is via sess_destroy() function. It works well. However session doesn't get destroyed when browser is closed. This is what I want to achieve. If user forget logout link,I want session to be destroyed with each closing browser.
I've been looking through user guide, but seems like can't find the answer.


Destroyed session with closed browser - El Forum - 04-17-2010

[eluser]Bart v B[/eluser]
you need to edit /application/config.php

these lines:

Code:
$config['sess_cookie_name']    = 'ci_session';
$config['sess_expiration']    = 7200; // this to 1 or something
$config['sess_encrypt_cookie']    = TRUE;
$config['sess_use_database']    = FALSE;
$config['sess_table_name']    = 'ci_sessions';
$config['sess_match_ip']    = TRUE;
$config['sess_match_useragent']    = TRUE;
$config['sess_time_to_update']     = 300;



Destroyed session with closed browser - El Forum - 04-17-2010

[eluser]babazumbula[/eluser]
If I put 1 that means cookie will expire in one sec? What if I want to redirect them to other member's page which needs this cookie?


Destroyed session with closed browser - El Forum - 04-17-2010

[eluser]Bart v B[/eluser]
hmmm. did not thought aboute that.. :red:

Maybe this is a better solution:
http://ellislab.com/forums/viewthread/109645/#553043


Destroyed session with closed browser - El Forum - 04-18-2010

[eluser]Ngulo[/eluser]
sorry man, are you using session library to work with users data?

what i mean is.... do you make this?:
in Login page:
Code:
$this->session->set_userdata('user');

and in Logout page:

Code:
$this->session->unset_userdata('user');

??
is this what's gonna creating problems to you?

for me there's no problem in users Login and Logout using session library

probably i didn't mean the way you're looking to make the login-logout app Tongue


Destroyed session with closed browser - El Forum - 04-20-2010

[eluser]WanWizard[/eluser]
The search engine would have revealed http://ellislab.com/forums/viewthread/128927/#636611, where I describe a solution to this problem (which is that CI doesn't interpret a zero value as 'valid till end of browser session', but defaults to two hours).