9

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 Answer 1

40

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;

...
3
  • If you don't want to use the default $_SESSION to store the state, you can extend the storeState class using this linked example. The example uses Laravel sessions but you can use whatever you want inside your extension. Sep 25, 2014 at 16:44
  • Yupp That worked for me, Thank You So much @Niraj Shah. I forgot to use redirectloginhelper.
    – Akilsree1
    Mar 12, 2015 at 6:07
  • 1
    You've got to be kidding me... All this time I was looking into Facebook session...
    – Slavic
    Apr 15, 2015 at 9:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.