Welcome Guest, Not a member yet? Register   Sign In
Session w/multiple databases ?
#1

[eluser]krsanky[/eluser]
I want to try using a database with my sessions.
The issue is I have two databases. The default and most oft used database is a MS Sql Server instance on another machine. The webserver also has a local Mysql database running. I want to connect to the local mysql one for session stuff.

To get this to work (using the NOT default database with sessions) I had to edit the Session.php library file.

It seems to work, but is this the right way? (or is there a better way?)

Basically I changed the way that Session.php loads the database:
Code:
//$this->CI->load->database('local');
$this->CI->local_db = $this->CI->load->database('local',TRUE);

The commented out line is the original.

I then did a search/replace from
Code:
$this->CI->db
to
Code:
$this->CI->local_db
in the rest of the Session.php file.

Like I said it seems fine, but I don't like editing the core library stuff.

So is there a better way?

thanks,
paul w
#2

[eluser]Randy Casburn[/eluser]
You should really use a separate library file named MY_session or something and place it in your application/libraries directory. This way you can override the native session library without hacking the core library.

Here is a file for you to work with: http://ellislab.com/forums/viewthread/89886/

I too need to support multiple databases with sessions. If this is something that is important to you, then add a comment to the post above and see if there is other interest in the community.

Maybe someone else is interested too.

Randy




Theme © iAndrew 2016 - Forum software by © MyBB