How to implement Facebook Graph API Logout function to logout from your web appliaction with your facebook session and remove all related cookies

On your js file :-

function logout(){
FB.getLoginStatus(handleFBSessionResponse);
location.href = '/user_sessions/new';
}

// handle a session response from any of the auth related calls
function handleFBSessionResponse(response) {
/*
//Check the facebook login status
alert("handleFBSessionResponse(), "
+ "\nresponse.status="+response.status
+" \nresponse.session="+response.session
+" \nresponse.perms="+response.perms);
*/
//if we do have a non-null response.session, call FB.logout(),
//the JS method will log the user out
//of Facebook and remove any authorization cookies
FB.logout(handleFBSessionResponse);
}

on your html file :-

< href="javascript:logout();">Logout< / a >


Enjoy ... :-) !!!

No comments

Powered by Blogger.