framework/web/DbSession.php
public function init()
    {
        parent::init();
        $this->db = Instance::ensure($this->db, Connection::className());
    }
public function init()
    {
        parent::init();
        $this->db = Instance::ensure($this->db, Connection::className());
    }
Initializes the DbSession component.
This method will initialize the [[db]] property to make sure it refers to a valid DB connection.
@throws InvalidConfigException if [[db]] is invalid.