It has been a while since this question has been asked, but I feel like a conclusive answer is needed.
As of CodeIgniter 2.1.2
When the system/libraries/Session.php
is loaded, it also loads a database to use with the sessions, if specified.
The default code used is (Line 85):
// Are we using a database? If so, load it
if ($this->sess_use_database === TRUE AND $this->sess_table_name != '')
{
$this->CI->load->database();
}
This should, in theory load the default database. For some reason, this did not work for me. I had to modify the code to specifically call the default database.
The code you should use to pull from the default
database:
// Are we using a database? If so, load it
if ($this->sess_use_database === TRUE AND $this->sess_table_name != '')
{
$this->CI->load->database('default', TRUE);
}
If you would like to use a different database, just change default
to the name of the database which you would like to use.
Note: If you load another database before you call session data, you will need to specify your session data again. The session will continue to try and pull from the currently active database.