Problem Description: easyii own original background was written Log, as shown below. After clicking the Log, the page will automatically jump to the page login. But the problem is, when the browser click to return, or still can enter into the background, Log did not play a role.
the reason:
Log calling method is: Yii :: $ app-> user-> logout ();
This method is written in the \ vendor \ yiisoft \ yii2 \ web \ User.php this file
You can see the 336 line, it returns $ this-> getIsGuest (); this method is to determine whether the current user for tourists, if it is true then return visitors;
enter this method
You can see this is to get the user currently logged on, and then determine whether or equal to null, if the current user information ($ this-> getIdentity) equal to null, then return true
Then enter this method:
Here you can see, this last method returns user information currently logged on. But between what he did, he judged, and if automatic login exists, he will be based on existing user id session, to pull back full user information, once set up automatic login, but still exists in the user's session id , then this method returns the user are true. So Log simply no role.
Solution: In the configuration file, the automatic login is set to false,
I was in After setting, still without success Log, because the session is not removed, so in the end I added, before the Log method of manually remove the session
Complete
Times to use the article yii2 novice, or just learning php students, for reference, in case the same problem, try using the above methods to solve.