持久数据中缺少必需的参数状态

Required param state missing from persistent data

我对 php-graph-sdk 有疑问,我有那些功能

 protected function getFacebook()
    {
        static $facebook = null;
        if($facebook == null){
            $facebook =  new Facebook\Facebook([
                'app_id' => $this->getAppId(),
                'app_secret' => $this->getAppSecret(),
                'default_graph_version' => 'v2.10'
            ]);
        }
        return $facebook;
    }
public function getLoginUrl($url)
    {
        $fb = $this->getFacebook();
        
        $helper = $fb->getRedirectLoginHelper();
        
        $autorisations = ['email']; 
        return $helper->getLoginUrl($url , $autorisations);
    }
 public function callback(&$error = null)
    {
        $fb = $this->getFacebook();
        
        $helper = $fb->getRedirectLoginHelper();
        
        try {
            $accessToken = $helper->getAccessToken();
        } catch(Facebook\Exception\ResponseException $e) {
            // When Graph returns an error
            $error = 'Graph returned an error: ' . $e->getMessage();
            return false;
        } catch(Facebook\Exception\SDKException $e) {
            // When validation fails or other local issues
            $error = 'Facebook SDK returned an error: ' . $e->getMessage();
            return false;
        }
        ....
  }

我也是

 $url = $Facebook->getLoginUrl(URL);

并且在回调文件中

$token = $Facebook->callback($error);

当我点击 link 时,回调文件被执行并且 $helper->getAccessToken();导致此错误: 未捕获 Facebook\Exceptions\FacebookSDKException:跨站点请求伪造验证失败。持久数据中缺少必需的参数“state”。

我看过有关该问题的帖子,但没有适合我的修复方法

编辑: 我目前发现的是: Cross-site request forgery validation failed required param state missing from persistent datahttps://github.com/facebookarchive/php-graph-sdk/issues/1123 https://github.com/facebookarchive/php-graph-sdk/issues/1134

最后,我通过在 config.php 中添加 samesite 到 Lax 解决了我的问题 ini_set('session.cookie_samesite','Lax');