Extending the Session Library - I need to specify database to store sessions in. - 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: Extending the Session Library - I need to specify database to store sessions in. (/showthread.php?tid=39176) |
Extending the Session Library - I need to specify database to store sessions in. - El Forum - 03-03-2011 [eluser]Jaketoolson[/eluser] I want to store my session activity in the database. I've updated my config file to reflect these changes: Code: $config['sess_encrypt_cookie'] = TRUE; The problem I'm having is my website utilizes more than 1 database, and I need to specify which database the sessions should be stored to. I tried extending the session library but it didn't do a thing: Code: class MY_Session extends CI_Session Extending the Session Library - I need to specify database to store sessions in. - El Forum - 03-03-2011 [eluser]danmontgomery[/eluser] Couple of things here... When you pass TRUE as the 2nd parameter, the DB object gets returned, not assigned to $CI->db. You would need to assign that DB object to something. Code: $this->sess_db = $this->CI->load->database($this->database_name, TRUE); Then, you'd need to do work in pretty much every method in the session class, and replace calls to $this->CI->db with whatever class member you assigned your session db to. sess_read(), sess_write(), etc. Code: /** etc. Extending the Session Library - I need to specify database to store sessions in. - El Forum - 03-03-2011 [eluser]Jaketoolson[/eluser] Thanks for the help!! I wish I could just set a variable in config and specify the DB there. |