太久没用php自带的session,导致用这段代码测试的时候,没有开启session,$_SESSION 永远是空的,于是每个请求都走了一次微信验证

Zerozh 2016-01-08 01:29:48 +08:00
parent 231b28767a
commit 1264f1d355

@ -104,6 +104,7 @@ $auth->authorize($to = null, $scope = 'snsapi_userinfo', $state = 'STATE')
```php
// 请一定要自己存储用户的登录信息,不要每次都授权
session_start();
if (empty($_SESSION['logged_user'])) {
$user = $auth->authorize(); // 返回用户 Bag
$_SESSION['logged_user'] = $user->all();