Facebook SDK returned an error: Cross-site request forgery validation failed. Required param "state" missing from persistent data.
I already put this code above my auth.php and callback.php
if (!session_id()) {
session_start();
}
The login with facebook button works only on admin accounts. But it is not working on other Facebook accounts. It displays the cross-site error
Try this
$fb = new \Facebook\Facebook([
'app_id' => $this->fb_app_id,
'app_secret' => $this->fb_app_secret,
'default_graph_version' => 'v2.10',
]);
$helper = $fb->getRedirectLoginHelper();
if (isset($_GET['state'])) {
$helper->getPersistentDataHandler()->set('state', $_GET['state']);
}
It works for me.
Thank you for using the Facebook PHP SDK!
If you need assistance using it, you should ask your questions on StackOverflow and tag them with the facebook-php-sdk tag.
So I'm closing this, but if you find a bug in the SDK or have a feature request, feel free to open a new GitHub issue.
Facebook SDK returned an error: Cross-site request forgery validation failed. Required param "state" missing from persistent data
Solution.....................????
@farhanakram1 do what Sammy suggested: ask StackOverflow :)
Try this
$fb = new \Facebook\Facebook([ 'app_id' => $this->fb_app_id, 'app_secret' => $this->fb_app_secret, 'default_graph_version' => 'v2.10', ]);
$helper = $fb->getRedirectLoginHelper(); if (isset($_GET['state'])) { $helper->getPersistentDataHandler()->set('state', $_GET['state']); }
It works for me.
you save my day thank you
Try this
$fb = new \Facebook\Facebook([ 'app_id' => $this->fb_app_id, 'app_secret' => $this->fb_app_secret, 'default_graph_version' => 'v2.10', ]);
$helper = $fb->getRedirectLoginHelper(); if (isset($_GET['state'])) { $helper->getPersistentDataHandler()->set('state', $_GET['state']); }
It works for me.
Working as expected ! Thanks.
if (isset($_GET['state'])) { $helper->getPersistentDataHandler()->set('state', $_GET['state']); }
finally there is a real solution, thanks.
Hi All
I have face issue "Facebook SDK returned an error: Cross-site request forgery validation failed. Required param "state" missing from persistent data." i am using the super socilizer plugin .
The same code work for me but i dont want to change in the plugin file then how i customize the plugin file please help me
Most helpful comment
Try this
$fb = new \Facebook\Facebook([ 'app_id' => $this->fb_app_id, 'app_secret' => $this->fb_app_secret, 'default_graph_version' => 'v2.10', ]);$helper = $fb->getRedirectLoginHelper(); if (isset($_GET['state'])) { $helper->getPersistentDataHandler()->set('state', $_GET['state']); }It works for me.