views:

52

answers:

2

How i can check is my visitor is logged in to Facebook?

I can use Social Graph api functions or similiar? I want to run conditional in Javascript on my page and display some content depending on that condition. If it's impossible - maybe i can check (via a:visited css or similiar) is somone visited Facebook recently? Thanks.

+3  A: 

You can't just check if someone is logged into Facebook without their consent, there are serious privacy issues with that. You can use the Facebook APIs provided to ask your user to authorize you to fetch certain data from their Facebook account.

See http://developers.facebook.com for more information.

Andy E
A: 

If you subscribe to auth.statusChange event, it might do the trick, as noted on this page:

Typically you will want to use the auth.sessionChange event. But in rare cases, you want to distinguish between these three states:

  • Connected
  • Logged into Facebook but not connected with your application
  • Not logged into Facebook at all.

The FB.Event.subscribe and FB.Event.unsubscribe functions are used to subscribe to these events.

Returned status would contain either connected, notConnected (logged in to facebook but not to your app) or unknown.

I am not sure if this would work as planned though as I haven't tried it myself. It might return notConnected status only for users that authorized your app in the past, but it seems like a step in the right direction.

serg