Cannot login after logout

Hi,

After I logout, on my home page it shows that I can login, when I click on login link, It automatically logs me in with the previous user. I have set enableAutoLogin to true and I am using a db to store sessions.

web.php





'user'            => [

                'identityClass'   => 'app\models\User',

                	'enableAutoLogin' => true,

            ],

 'session' 		=> [

                'class'      => 'app\components\DbSession',

                   'useCookies' => true,


            ],



What is wrong?!

P.S. my DbSession is in components because I Have I have changed session->write() to store user id in db.

It looks like your "login" page requires a logged-in user. I mean, it is not allowed to guests, and so the auto-login is triggered.

Would you please check your access control filter of the controller?

Thanks for your answer. The filter you mentioned is empty since everyone can access the page.

This is my login code:





public function actionLogin()

        {

            Yii::$app->publicFunctions->checkPermissions('site', 'login');

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

                return $this->goHome();

            }


            $model = new LoginForm();

            if ($model->load(Yii::$app->request->post()) && $model->login()) {

	                return $this->redirect(Yii::$app->request->baseUrl . '/myprofile');

            } else {

                $pageTitle = 'Login';

                return $this->render('login', [

                    'pageTitle' => $pageTitle,

                    'model' 	=> $model,

                ]);

            }

        }




This is the questionable part. What does this do?

Usually “login” page doesn’t need any permission checking.

This returns true since there are no records inserted in the database to check permission of this action. Even after removing that line, the problem won’t be solved.

Thanks for your patience in helping me through this.

No one can help me with this?

I would use my IDE (PhpStorm) to do a step-by-step tracing in a situation like this.