How to get Facebook login button to display "Exit"

I apologize ahead of time if this is clearly documented somewhere on the FB developer site, but I cannot find it (so please post a link if necessary).

I have embedded the FB login button on the website using GAE + Python. Here is the HTML:

<fb:login-button></fb:login-button> <div id="fb-root"></div> <script src="http://connect.facebook.net/en_US/all.js"></script> <script> FB.init({appId: 'ad16a806fc10bef5d30881322e73be68', status: true, cookie: true, xfbml: true}); FB.Event.subscribe('auth.sessionChange', function(response) { if (response.session) { // A user has logged in, and a new cookie has been saved } else { // The user has logged out, and the cookie has been cleared } }); </script> 

Currently, the behavior - if I click the "Login" button, I am asked to allow the application access to FB. Then I select "OK." But then the login button still shows "login", not "logout". How to implement this? Server or client side?

+6
javascript python facebook facebook-graph-api
source share
4 answers
0
source share

It is not documented on the FB SDK page of the login page for any reason, but you can add the autologoutlink="true" attribute to the tag and it will show the exit button if you are logged in, and not just make the button invisible.

 <fb:login-button autologoutlink="true"></fb:login-button> 

Warning : it will ignore this tag if you use custom text in the login button, for example

 <!-- This will always display the button, whether you are logged in or out --> <fb:login-button autologoutlink="true">Login To My Service!</fb:login-button> 
+24
source share

This is confirmed at https://developers.facebook.com/docs/reference/plugins/login/ . You can also check onlogin for your callback.

0
source share

Derek did not mention the HTML5 alternative that he recommended:

 <div id="fbloginbut" scope="user_birthday" onlogin="checkLoginState();" class="fb-login-button" data-max-rows="1" data-size="large" data-show-faces="false" data-auto-logout-link="true"></div> 

The next page will create the code for the login / logout button that you like best: https://developers.facebook.com/docs/plugins/login-button

0
source share

All Articles