YII - 我们如何在控制器的init()函数中获取方法的名称?

In a YII work, I have an init() function which checks whether the session is set if not redirect to login page.

The problem is that the "login" action is also in the same controller, so it is creating an infinite loop. If I can get the method name in init() function, I can solve this issue.

How I can get the method name in init() function?

Current Controller

Yii::app()->controller->id 

and Current Action

Yii::app()->controller->action->id

To check action id in all functions other than init(), because init function initializes the controller...

So the solution for your problem will be let the request come to the actionLogin in your login controller..and there you check if session is not check redirect him from where he is coming..else perform the login action..That way you'll not face loop problem..