diff --git a/网页授权.md b/网页授权.md index 3ead8f6..6c4f930 100644 --- a/网页授权.md +++ b/网页授权.md @@ -106,11 +106,13 @@ $auth->authorize($to = null, $scope = 'snsapi_userinfo', $state = 'STATE') // 请一定要自己存储用户的登录信息,不要每次都授权 if (empty($_SESSION['logged_user'])) { $user = $auth->authorize(); // 返回用户 Bag - $_SESSION['logged_user'] = $user; + $_SESSION['logged_user'] = $user->all(); // 跳转到其它授权才能访问的页面 +} else { + $user = $_SESSION['logged_user']; } -var_dump($_SESSION['logged_user']); +var_dump($user['openid']); ``` 如果你不想用默认的逻辑,你也可以自己使用下面单独的方法来完成授权的操作: