Yii框架登录后重定向页面 [英] Redirect page after login in Yii framework

查看:33
本文介绍了Yii框架登录后重定向页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Yii 框架的新手.在 Yii 中,当您默认登录时,它会重定向到索引页面.我希望当我登录到 Yii 时,页面将重定向到另一个页面而不是索引页面.所以任何人都可以帮助我.任何帮助或建议都将受到高度赞赏.

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 page not the index page. So can anyone help me in this. Any help or suggestions will be highly appreciable.

当我使用用户模块时重定向将如何工作,因为登录后页面被重定向到个人资料页面?

how the redirect will work when I will use user module as after login the page is redirected towards profile page?

推荐答案

您可以(实际上,如果要发生任何重定向,则必须)指定要重定向到控制器 actionLogin 方法.登录成功后,你会看到类似这样的代码:

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);

将此更改为 CController::redirect方法支持,可以控制用户登录后重定向到哪里.

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

顺便说一句,使用 Yii::app()->user->returnUrl 使重定向页面能够将用户返回到他们打算访问的 URL,然后再被重定向到登录页面.

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.

这篇关于Yii框架登录后重定向页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆