Redirect page after login in Yii framework

前端 未结 4 1466
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-12 10:59

I am newbie to the Yii Framework. In Yii when you login by default it redirects to the index page. I want that when I will login to Yii the page will redirect to another pag

4条回答
  •  没有蜡笔的小新
    2021-01-12 11:34

    You can (and indeed, must, if any redirection is going to take place) specify the URL to redirect to inside your controller's actionLogin method. After a successful login, you will see something like this code:

    $this->redirect(Yii::app()->user->returnUrl);
    

    Change this to any parameter that the CController::redirect method supports, and you can control where the user is redirected after login.

    As an aside, using Yii::app()->user->returnUrl enables the redirect page to return the user back to the URL they intended to visit before being redirected to the login page.

提交回复
热议问题