CodeIgniter Forums
Session to Database + Multiple Database - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: Session to Database + Multiple Database (/showthread.php?tid=58307)



Session to Database + Multiple Database - El Forum - 06-01-2013

[eluser]Unknown[/eluser]
Hello,

I want now that the sessions will be save in my database.
But my default database is not my database for stuffs like ci_sessions.

I found this:
Tutorial

So I edited the Session.php in system/lib with:
Code:
// Are we using a database?  If so, load it
  if ($this->sess_use_database === TRUE AND $this->sess_table_name != '')
  {
    $this->CI->load->database('stuff', TRUE);
  }

But the system still want connect to my default database :/

Someone a solution to get the session_db on my stuff_database?


Thanks Smile
Sanjo



Session to Database + Multiple Database - El Forum - 06-03-2013

[eluser]XMadMax[/eluser]
Samjo,

Code:
$this->CI->load->database('stuff', TRUE);

This load the stuff configuration, and returns the pointer to this connection. You must use:

Code:
$this->stuffdb = $this->CI->load->database('stuff', TRUE);

And use $this->stuffdb instead of $this->db

Also, another solution would be to create a db function inside session. When $this->db are called, you can return your own database, instead of default database.

Xavier