Answer the question
In order to leave comments, you need to log in
The site has redirected too many times, how to solve?
Hello! I'm using advanced version of yii2 and /admin has an admin login form. And I added the admin column with the values 0 and 1 in the user table. Now I
put the following check in the controller
public function actionIndex()
{
if (Yii::$app->user->isGuest || Yii::$app->user->identity->admin!=1) {
return $this->redirect('/admin/site/login');
}
return $this->render('index');
}
Answer the question
In order to leave comments, you need to log in
You have a problem with multiple redirects. I assume that this index is your main page. And in the controller /admin/site/login
you have a redirect to goHome()
. What is the result? You get to the main page, you are redirected to the login, the login redirects to the home page. And here is your cycle. I suspect it is
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question