Skip to content

Instantly share code, notes, and snippets.

/fb-logout-code Secret

Created July 31, 2012 15:37
Show Gist options
  • Save anonymous/d4952a6ba58c8aa961ff to your computer and use it in GitHub Desktop.
Save anonymous/d4952a6ba58c8aa961ff to your computer and use it in GitHub Desktop.
Facebook Logout Issue
HTML:
<div class="fb-like-box" data-href="<?=$fblike;?>" data-width="500" data-show-faces="false" data-stream="false" data-header="false"></div>
<a href="javascript:void(0);" onclick="redirect();">Logout from facebook &amp; continue!</a>
JS:
function redirect() {
window.location = l;
}
window.fbAsyncInit = function() {
FB.init({
appId : '<?=$this->facebook->appid;?>',
status : true,
cookie : false,
xfbml : true
});
FB.Dom.ready( function(){
FB.getLoginStatus(function(response){
$('#logout_link a').attr('onclick',"FB.logout(redirect);");
<?php if(!$fblike) { ?> FB.logout(redirect); <?php } ?>
});
});
};
// Load the SDK Asynchronously
(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));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment