Session not being destroyed upon the browser closure - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Session not being destroyed upon the browser closure (/showthread.php?tid=23276) |
Session not being destroyed upon the browser closure - El Forum - 10-05-2009 [eluser]Unknown[/eluser] Hello, My CI app is keeping the sessions even after I close the browser and restart it. Why is that? Thanks. Session not being destroyed upon the browser closure - El Forum - 10-06-2009 [eluser]überfuzz[/eluser] You're not giving away much to correct here are you? Is there any code corresponding to the problem you're facing? Try this: Code: $this->session->sess_destroy(); Session not being destroyed upon the browser closure - El Forum - 10-06-2009 [eluser]WanWizard[/eluser] The current CI session library doesn't support the option at the moment. Normally you would use a session timeout value of zero, which on the session cookie means 'valid until the browser closes'. However, the CI session library says: Code: // Set the session length. If the session expiration is I solved this by adding this bit of code to my MY_Session library (create it if you don't have one): Code: // call the parent constructor Session not being destroyed upon the browser closure - El Forum - 10-07-2009 [eluser]Refringe[/eluser] @WanWizard: Could you please elaborate on how to create your "MY_Session" library? I've created the file: application/libraries/MY_Session.php MY_Session.php contents: Code: class MY_Session extends CI_Session { Then to load MY_Session I add it to the autoload array in: application/config/config.php Code: $autoload['libraries'] = array('session', 'my_session'); Is this correct? Session not being destroyed upon the browser closure - El Forum - 10-07-2009 [eluser]Refringe[/eluser] That can't be right. It's setting two sessions for every one visit. Session not being destroyed upon the browser closure - El Forum - 10-07-2009 [eluser]Colin Williams[/eluser] You don't need to autoload MY_Session. CI will include and instantiate it automatically Session not being destroyed upon the browser closure - El Forum - 10-07-2009 [eluser]Refringe[/eluser] Great! It's working now. What I've ended up doing is changing WanWizard's code so the $config['sess_expiration'] variable can still be used, however if the value is set to "0" then it's kept that way. A little more extendable that way, I think. Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); Thanks for your help. |