Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • logout from facebook with javascritp SDK - facebook logout

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 115
    Comment on it

    For creating logout from facebook we need the facebook javascript SDK.

    Code snippets to logout from Facebook is given below :

    <script>window.fbAsyncInit = function() {
                    FB.init({
                        appId      : "FACEBOOK_APPLICATION_ID", 
                        status     : true, 
                        cookie     : true,
                        xfbml      : true,
                        oauth      : true                    
                    });
                    FB.getLoginStatus(function(response) {
                    if (response && response.status === 'connected') {
                        FB.logout(function(response) {
                           /** Afer logout, Refresh the Page **/ 
                           console.log('Logout Successfully.');
                           document.getElementById('currentStatus').innerHTML='Logout from facebook Successfully.';
                           //document.location.href='/';
                           /** Afer logout, Refresh the Page **/                        
    
                        });
                    }else{
                        //document.location.href='/';                    
                        document.getElementById('currentStatus').innerHTML='You are NOT LOGIN in Facebook.';
                        console.log('You are not login in Facebook.')
                    }
                });
    
    
                }; 
    
                (function(d){
                    var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
                    js = d.createElement('script'); js.id = id; js.async = true;
                    js.src = "//connect.facebook.net/en_US/all.js";
                    d.getElementsByTagName('head')[0].appendChild(js);
                }(document));
            </script>
            <h2 id="currentStatus">
    Please wait...</h2>
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: