Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

logout button in FaceBook SDK

I have this fb-login button on my website and it works pretty okay. How can I implement an logout button? Below is my code for the login part.

<fb:login-button size="small" onlogin="RedirectLogon();" perms="email,user_birthday" autologoutlink="true">
    <%=LanguageManager.Instance.Translate("root/facebook/login")%>
</fb:login-button>
like image 577
Niklas Hultgren Avatar asked Apr 15 '11 17:04

Niklas Hultgren


2 Answers

If you want to implement such buttons into one multifunctional button, use this:

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

Note that if you add any custom code to the above line, the button won't work.

like image 64
magicode118 Avatar answered Nov 23 '22 23:11

magicode118


You can do it by using the following HTML and javascript function.

<script>
function fbLogout() {
        FB.logout(function (response) {
            //Do what ever you want here when logged out like reloading the page
            window.location.reload();
        });
    }
</script>

<span id="fbLogout" onclick="fbLogout()"><a class="fb_button fb_button_medium"><span class="fb_button_text">Logout</span></a></span>
like image 38
Siva Avatar answered Nov 23 '22 23:11

Siva