randy
randy

Reputation: 1877

how to tell if the user is already logged in and has already accepted my app

I am just creating a facebook tab on a users page. I am using the php facebook SDK, and this little snippet(see below) from the tutorials. My question is , if the user is logged into FB and comes back to my page later $user is not found and they have to connect again. Is there not a way to know that they are already logged in and already granted me access?

I hope this question makes sense

$facebook = new Facebook(array(
    'appId'  => FB_APP_ID,
    'secret' => FB_APP_SECRET,
    'cookies' => 'true'
));
$user = $facebook->getUser();

if ($user) {
    $logoutUrl = $facebook->getLogoutUrl();
} else {
    $loginUrl = $facebook->getLoginUrl(array('scope' => 'publish_stream, manage_pages'));
}

Upvotes: 0

Views: 160

Answers (1)

zerkms
zerkms

Reputation: 254886

Nope, it won't be done automagically on server-side. To know who user is - you need to ask them to follow the login url

OR

use JS SDK. In that case user is logged in automatically and all you need is to refresh the page by JS (there is an example shipped with php sdk on how to do that)

Upvotes: 1

Related Questions