Support Forums - Classified Ads Script Osclass
Osclass plugin support => Free Osclass Plugins => Facebook Login Plugin => Topic started by: Olegs on May 23, 2019, 11:46:06 PM
-
such an error periodically comes out, we cannot understand what it is the reason.
but after 2-3 minutes it disappears, and the login is done successfully, but after leaving the profile, you can’t go back, this error appears again
Facebook SDK returned an error: Cross-site request forgery validation failed. The "state" param from the URL and session do not match.
-
I got this error once as well, then never again.
-
Its looks like the problem is in the code,
Found this in one forum,
There could be 2 reason for this error:
you didn't call session_start(); before getLoginUrl call
You executed getLoginUrl again in login-callback.php, so state value regenerated and mismatched with the redirected value
and
I had the same problem.
The reason for this error is because --->
When "$helper->getLoginUrl" calls, it create a session variable "FB_State", and this is something to FB uses to match the token. Every-time getLoginUrl calls, it create new state. Then after user authorized and redirect back, if you codes cannot detect this event and re-run "$helper->getLoginUrl", then this error will occur.
The solution ->
refine your coding, stop run "$helper->getLoginUrl" again if authorized.
if you already rerun, then set the session variable for the token to NULL if you have, then User can re-authorize again.
when user tries re-authorize, they can remove the authorized APP once or you need to generate new link with "$helper->getReRequestUrl"
Yet, token has be called by "getAccessToken()" before the "$helper->getLoginUrl" or "$helper->getReRequestUrl" runs.
Good Luck!!!!!
@MbThemes, maybe you can help with that
-
@MbThemes,
the reason of this issue is cache plug-in, When I turn off the cache on the home page, fb login plugin working properly and without errors. As soon as I turn ON cache on Home page, this message appears.
I hope that you look at the possibility of correcting this error.
Thanks
-
That is strange, plugin should disable cache when fb login request is coming
-
I'm facing the same problem, And i dont have cache plugin! any advice?
-
I found this solution to fix it guys we need to insert below code after $helper = $fb->getRedirectLoginHelper();
if (isset($_GET['state'])) {
$helper->getPersistentDataHandler()->set('state', $_GET['state']);
}
Read more at:
https://stackoverflow.com/questions/32029116/facebook-sdk-returned-an-error-cross-site-request-forgery-validation-failed-th