I am from a hard place along with a rock having a CI problem. I must dynamically connect with a DB using the account information that customers type. Individuals are their oracle passwords. So, with this information I must perform the link with the DB after which ensure that it stays alibe for that different types and remotes inside the application.

I've got a login controller along with a login view. I have disabled the database autoload in the database.php and config.php files.

Then, the login.php controller appears like this:

class Login extends CI_Controller {

public function index()
{
    $this->output->enable_profiler(TRUE);

    if (isset($_POST['ingresar'])){

        $db['hostname'] = 'myhost';
        $db['username'] = $_POST['usr'];
        $db['password'] = $_POST['pwd'];

        $db['database'] = 'DBname';
        $db['dbdriver'] = 'oci8';
        $db['dbprefix'] = '';
        $db['pconnect'] = FALSE;
        $db['db_debug'] = FALSE;
        $db['cache_on'] = FALSE;
        $db['cachedir'] = '';
        $db['char_set'] = 'WE8ISO8859P1';
        $db['dbcollat'] = '';
        $db['swap_pre'] = '';
        $db['autoinit'] = TRUE;
        $db['stricton'] = FALSE;



        $db['DB'] = $this->load->database($_SESSION, TRUE);

        redirect('contactos', 'location');
    }
    else{
        $this->load->view('/componentes/header');
        $this->load->view('/componentes/menu_sin_login');
        $this->load->view('/login/login');
        $this->load->view('/componentes/footer');
    }       
}

Once the controller redirects towards the other controller "contactos" everything crashes since it does not recognize a database connection, online 5, when attempting to load one.

class Contactos extends CI_Controller {
public function __construct()
{
    parent::__construct();
    $this->load->model('Contactos_model');
    $this->load->model('Componentes_model');.....

Any assist you to can offer could be really appreciated.

Regards, V

Within the context above $db is really a local variable, meaning it does not do anything concerning the larger context from the script, and you are not storing it anywhere that could be re-used.

To load the DB, you most likely wish to call:

// you may want to think about using an encrypted CI session instead?
$_SESSION['DB'] = $db;

then, in contactos, you'd want:

class Contactos extends CI_Controller {
public function __construct()
{
    parent::__construct();
    $this->load->database( $_SESSION['DB'] );
    // continue as above.