How to dynamically set the defaultRoute?

I have functionality which available only for logged users. And if user login, he redirects to //site.name/advanced/index. How I can do, if user login, that controller calls by //site.name/ without advanced/index.

In two words - how to dynamically set the defaultRoute configuration?

I googled this, but it didn’t work for me.

Thanks.

Solved my problem in this way.




class SiteController extends Controller

{

  public function actionIndex()

  {

    if (!Yii::$app->user->isGuest) {

      return Yii::$app->runAction("advanced/index");

    }

  }

}