Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stackoverflow's style login with facebook account

Tags:

facebook

login

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...

like image 581
T1000 Avatar asked Nov 08 '10 12:11

T1000


1 Answers

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());
    }
like image 120
Gazler Avatar answered Sep 29 '22 13:09

Gazler