Support the ongoing development of Laravel.io →
Authentication Session Packages
Last updated 1 year ago.
0

Are you sure you set the the "FBRLH_state" key in $_SESSION? You can use Session::put in Laravel to do this, and Session::get to retrieve the data (that way it won't die on an undefined index error). If you're already doing this somewhere else, check if there's anything even in $_SESSION["FBRLH_state"].

Last updated 1 year ago.
0

@s1dd, I didn't set anything. I believe facebook has set the session. I am just trying to get an access_token to get the user's profile. Thank you.

Last updated 1 year ago.
0

According to Facebook's documentation for the PHP SDK: https://developers.facebook.com/docs/php/FacebookRedirectLogin...

"Then, in your callback page (at the redirect url) when Facebook sends the user back:

$helper = new FacebookRedirectLoginHelper($redirect_url);
try {
    $session = $helper->getSessionFromRedirect();
} catch(FacebookRequestException $ex) {
    // When Facebook returns an error
} catch(\Exception $ex) {
    // When validation fails or other local issues
}
if ($session) {
  // Logged in.
}

You need a way to capture the response from the RedirectLoginHelper, and use it to generate the FacebookSession. You can use getSessionFromRedirect(), or manually process the POST data from Facebook. It's up to you, but as of now, you are doing neither.

Last updated 1 year ago.
0

@s1dd, Thank u for ur reply. How can I manually process the $_POST data?

Last updated 1 year ago.
0

I highly recommend using getSessionFromRedirect as it abstracts the pain of using the $_POST superglobal; however, if you're insistent on not using this method, I would just start by using a dd($_POST) to try and find the token in the response, and then save it to the session. I would suggest reading through the Facebook documentation for access tokens, as well as the PHP SDK to help gain a better understanding of how the RedirectLoginHelper works.

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.