Logout Problem

Good day!

Reviewed a lot of other topics, however, could not find any solution for my issue. So, decided to post it here in case someone knows how to solve it.

Well, I implemented autologin with Windows Authentication via IIS server. However, I was asked to make a logout button and redirect to login form (in case someone has another account) after logging out the user. This part works as well, however, when I click on any available link after logout, it logs the last user in with (and a strange thing: the error message saying that you have to be logged in to do this also appears). As if it is a cache or session related problem. I cannot image, what is the cause of this nonsense.

I have implemented the authentication like this:

  1. Autologin with Windows Authentication through $_SERVER[‘REMOTE_USER’] variable. I made a variable called type in order for the application to know what type of authentication is taking place.



        $splitted = explode("\\", $_SERVER['REMOTE_USER']);

        $username = $splitted[1];

        $identity = new UserIdentity($username, $password);

        $identity->setType('winlogin');

        if ($identity->authenticate()) {

            Yii::app()->user->login($identity);

            Yii::app()->user->setIsAdmin($identity->getUser()->admin);

            Yii::app()->user->setUserId($identity->getUser()->id);

            Yii::app()->user->setUserName($identity->getUser()->firstname . " " . $identity->getUser()->lastname);

            Yii::app()->user->setWinUserName($identity->getWinUser()->username);

            Yii::app()->user->setTypeOfLogin($identity->getType());

        }



  1. Then, i logout and redirect to another page.

	public function actionLogout() {

		Yii::app()->user->logout(true);

		$this->redirect(Yii::app()->baseUrl . Yii::app()->params['changeuserUrl']);

	}

  1. On that page I have a form, which is visible only if Yii::app()->user->isGuest is true.

  2. Clicking on any link when on this redirected page logs back in the user.

So, I am trying to figure out the cause of this disaster. If anyone may happen to know the reason, please, let me know here. Thank you very much in advance!!!

At last found out the reason. Actually, it is not related to logging out. If refers to returnUrl, which was set to index.php and I needed it to be another page. Sorry for taking your time! Thanks!