A
A
Artur Yalaltdinov2016-06-04 21:34:16
Facebook
Artur Yalaltdinov, 2016-06-04 21:34:16

Facebook login not working?

Hello everyone, I've run into a problem.
By clicking on the authorization button via facebook, it returns me to the main page where it should be, but does not want to work correctly.
When viewing the page through the source code and following the link from the source code everything works fine, what's the problem?
Handler code

if(isset($_GET['code']) && isset($_GET['state']))
{
  if($sessions = $facebook->getSessionFromRedirect()) {
    $_SESSION['facebook'] = $sessions->getToken();
    header('Location index.php');
  }

  if(isset($_SESSION['facebook'])) {
    $sessions = new Facebook\FacebookSession($_SESSION['facebook']);
    $request = new Facebook\FacebookRequest($sessions, 'GET', '/me', ['fields' => 'id, name, email']);
    $request = $request->execute();
    $fbuser = $request->getGraphObject()->asArray();
    setcookie("test", $fbuser['name'], 0, "/");
    print_r($fbuser);
  }
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question