I am trying to connect different database, once user is authenticated. I have used following code to connect database after successful login. But connection not remains active.
Yii::$app->set('db',[ 'class' => 'yii\db\Connection', 'dsn' => 'mysql:host=localhost;dbname='.$publishedWebsite->db_name, 'username' => $publishedWebsite->db_user, 'password' => $publishedWebsite->db_password, 'charset' => 'utf8', ]); Yii::$app->db->open();
So anyone can suggest me possible solution to resolve my problem.