thinkphp always reports an error when refreshing the front-end page for the first time
我想大声告诉你
我想大声告诉你 2017-05-27 17:42:51
0
1
516

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

我想大声告诉你
我想大声告诉你

reply all(1)
我想大声告诉你

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template