Facebook SDK login Popup

Asked

Viewed 131 times

0

I have a plugin login by facebook, I took this tutorial http://www.krizna.com/general/login-with-facebook-using-php/. so far so good, but I would like to put it to redirect to the same page on which is requested login, I’ve seen many sites do this with authentication popups. How can I add this popup function to redirect to the same page you requested to login?

1 answer

0

This popup you say is because they used the javascript SDK to log in with Facebook, not PHP , which is your case.

In your case you can do the following, in the Facebookredirectloginhelper method you pass the same URL of the login page and in it you check if the user is coming from a Facebook login as well as if it is already logged in.

For example, Facebookredirectloginhelper on an index.php would look like:

$helper = new FacebookRedirectLoginHelper('http://seusite/index.php');
...

and in itself to receive/verify the user back from the Facebook login page:

if ( !empty($_GET['code']) ){
...
$helper = new FacebookRedirectLoginHelper('http://seusite/index.php');
try {
  $session = $helper->getSessionFromRedirect();
} catch
...
  • when Facebook returns from login it brings this GET variable

Ps.: Logging into Facebook using the javascript SDK is extremely productive when possible.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.