Like the title
The code logic is very simple, as follows
if (empty($_SESSION['openid'])) {
// 这里是授权登录,数据库操作,存入session
$this->getUserDetail('fromWechatGetInfo');
// 这里是去前端页面
$this->goIndexWeb();
}else {
// 这里是去前端页面
$this->goIndexWeb();
}
}
But it’s very strange, that is, the first time I enter, I enter the page after authorized login. If I refresh it, an error will be reported. But if I re-enter, refresh the page and there will be no problem. Later I found that as long as the session expires, I will enter the page after authorized login. An error will be reported when the page is refreshed again. As long as the session has not expired and you enter the page through else, the error will not be reported after refreshing. What is the reason and how to solve it? Thank you
The assignment and acquisition of $session cannot be performed on the same page, otherwise the value of the session will not be obtained, so it is recommended to use tp’s built-in session