Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FacebookSDKException: Session not active, could not store state

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.

like image 763
SBel Avatar asked May 07 '14 15:05

SBel


1 Answers

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;

...
like image 50
Niraj Shah Avatar answered Oct 18 '22 18:10

Niraj Shah