5
votes

Hello I'm trying to make option for users to login to my site with their facebook accounts.
As far as I read in facebook api I have found only login with pop-up window, but I don't like It...
I'd like to make it like here on stackoverflow
1. user click on "login" image ot button
2. whole window goes to FB page and ask user for perm
3. get back user to my page...

1

1 Answers

9
votes

If you use:

http://github.com/facebook/php-sdk

You can do something along the lines of:

    $facebook = new facebook();
    $fbSession = $facebook ->getSession();

    //IF user is logged in
    if ($fbSession)
    {
        $_SESSION['fbsession'] = json_encode($fbSession);
    }
     else
    {
        header('Location: '.$facebook->getLoginUrl());
    }