Take the 2-minute tour ×

I apologize ahead of time if this is clearly documented somewhere on the FB developer site - but I can't find it (so please link me if appropriate).

I've implemented the FB login button on a website using GAE + Python. Here is the HTML:

  FB.init({appId: 'ad16a806fc10bef5d30881322e73be68', status: true, cookie: true, xfbml: true});
  FB.Event.subscribe('auth.sessionChange', function(response) {
    if (response.session) {
    } else {

Currently the behavior is - if I click on the "login" button, I am asked to allow the application access to FB. Which I then choose, "OK". But then the login button is still showing "login" and not "logout". How do I implement that? On the server or client side?

share|improve this question
Example github.com/facebook/python-sdk –  haha Dec 23 '10 at 21:32
Thanks I found the answer there! –  Will Merydith Dec 23 '10 at 21:48

4 Answers 4

Its not documented on the FB SDK login-button page for some reason, but you can add the autologoutlink="true" attribute to the tag and it will show a logout button if you are logged in rather than just making the button invisible.


Warning: it will ignore that tag if you are using custom text on the login button like

<!-- 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>
share|improve this answer
+1 for the warning! –  Thomas Dec 10 '11 at 10:25
+1 that stackoverflow people are awesome :) –  Faizan May 4 '13 at 9:20
This has been added to the docs at developers.facebook.com/docs/reference/plugins/login –  J Starr Jul 8 '13 at 20:57
up vote 0 down vote accepted

Thanks to user "haha" the solution is:

1) Grab the Facebook Python SDK: https://github.com/facebook/python-sdk/tree/master/examples/appengine 2) Implement the HTML example: https://github.com/facebook/python-sdk/blob/master/examples/appengine/example.html 3) Update your main request handler and models: https://github.com/facebook/python-sdk/blob/master/examples/appengine/example.py

share|improve this answer

This has now been documented at https://developers.facebook.com/docs/reference/plugins/login/ . You may also want to check out onlogin for your callback.

share|improve this answer

Derek did not mentioned the HTML5 alternative which is he recommended way:

<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 following page will generate the code for the login/logout button that you like the most: https://developers.facebook.com/docs/plugins/login-button

share|improve this answer

Your Answer


