简体   繁体   中英

How can I use sessions in codeigniter in more multiples database ?

I have a default database that I only use to log in, and after it I change the database using this:

$new_db = $this->load->database( $params, TRUE );
$this->db = $new_db;

After change database I have to store the session data into the second one but my sessions are storing in the first one and when I try to retrieve it, codeigniter looks for it on the second one. Does anyone knows why codeigniter has this kind of behavior and some ideia to solve this ? Thanks to help.

Why don't you try to reset session library? It's autoloaded, right? So it won't know the new database values because when the first load happened, your database value was the login database. Try to run $this->load->library('session'); after changing database.

Since session is actually a class on CI, it would be logical that it maintains the first reference until a new object take place.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM