FacebookSDKException: Session not active, could no

2019-03-19 07:45发布

I don't understand why I'm getting this exceptions:

Session not active, could not store state.

The code is:

<?php

require 'vendor/autoload.php';

use Facebook\FacebookSession;
use Facebook\FacebookRedirectLoginHelper;

FacebookSession::setDefaultApplication('foo', 'baz');

$helper = new FacebookRedirectLoginHelper('bar');
$loginUrl = $helper->getLoginUrl();

?>

Please help.

1条回答
▲ chillily
2楼-- · 2019-03-19 08:25

You need to start a session using session_start() for the Facebook SDK to work correctly. Please add this to your code to fix the issue.

Example:

<?php

session_start();

require 'vendor/autoload.php';

use Facebook\FacebookSession;
use Facebook\FacebookRedirectLoginHelper;

...
查看更多
登录 后发表回答