Finally, looking at the FB code, I found that the problem "Cross-site request forgery check failed. The required state of the parameter is" absent "and similar data is caused by the PHP variable $ _SESSION ['FBRLH_state'], which is for some" strange "reason when FB calls the login callback file.
To solve this problem, I save this variable "FBRLH_state" AFTER calling the $ helper-> getLoginUrl (...) function. It is very important to do this only after calling this function because the variable $ _SESSION ['FBRLH_state'] is inside this function.
Below is an example of my code in login.php:
$uri=$helper->getLoginUrl($uri, $permissions); foreach ($_SESSION as $k=>$v) { if(strpos($k, "FBRLH_")!==FALSE) { if(!setcookie($k, $v)) { //what?? } else { $_COOKIE[$k]=$v; } } } var_dump($_COOKIE);
And in login-callback.php before calling all the FB code:
foreach ($_COOKIE as $k=>$v) { if(strpos($k, "FBRLH_")!==FALSE) { $_SESSION[$k]=$v; } }
Last but not least, remember also to include code for your PHP session, therefore ..
if(!session_id()) { session_start(); } ... ... ... ... <?php session_write_close() ?>
I hope this answer helps you save 8-10 hours of work :) Bye, Alex.
source share