May
28

Facebook Connect Logout.

Tags:  Facebook Connect Logout 

Facebook Connect Logout
I have been getting a lot of users looking for either the Facebook Connect logout button or the way it is implemented. The Facebook Connect logout function is very easy to set up. All all you need to do is make sure you have included the following code in your page.

Note: I wont touch on basic Facebook Connect setup here, I assume you are already able to login successfully. If not, check out my post on setting up FBConnect from scratch.

HTML:
<a href = \"#\" onclick = \"FB.Connect.logout(function() { FBCLogout(); }); return(false);\">
<img id = \"fb_logout_image\" src = \"http://static.ak.fbcdn.net/images/fbconnect/logout-buttons/logout_small.gif\" alt = \"Connect\" />
</a>

JavaScript:
<script type="text/javascript">
function FBCLogout() {
FB.XFBML.Host.parseDomTree();
}
</script>


It's just that simple. The logout button is loaded directly from Facebook so no need to worry about that, and the anchor tag calls the FCBLogout() function I made to parse the DOM tree to update the Facebook authentication status.

I also like setting Facebook Connect logout this way because it allows you to add AJAX right in the JavaScript function above the FB code when you are ready to add it.

I hope this helps.

Comments

hi how to show the facebook login button and when click on it for login after login this login button must be hide and replece it logout button. please tell me code.


waiting
thanks advance

ashfaq over 3 years ago

i have a site that allows people to have accounts that are not linked to facebook accounts. we integrated facebook connect as an alternate login system.

as such when we log people in via either method we set a php session variable.

on log out we set up a php script to clear & destroy this session.

I'm having trouble getting the log out method here to redirect to the php script so the php sessions can be destroyed.


If i use this method the user is logged out of facebook but not our site. If i call the php script the user is logged out of our site but not facebook.

Any help would be appreciated.

jeff over 3 years ago

Do you know AJAX? that would solve your problem.

I have set the above example up in such a way that the FBClogout(); function can trigger an AJAX call to destroy your session. It is important to note that the FBClogout(); function is a function that I have created and not one included in the Facebook API.

If you don't know AJAX... get jQuery on your site. Look at the $.ajax() function. If you still can't get it, come back and post.

Marcus over 3 years ago

I was initially just trying to do a page redirect to the php page inside FBClogout(). That didn't work (not entirely sure why). I don't really know ajax / jquery so thats why i was just trying to redirect to the page.

I got the Ajax call going now though, it wasn't as painful as i thought it would be. Actually it was pretty easy considering it was my first atempt at the whole ajax thing.

Now it all works as it should.

Thanks for the advice.

Jeff over 3 years ago

i need to know how can i get data from facebook to save in my database. if someone give me same code that will be good. i need max info that fb gives.

pakistan web hosting over 3 years ago

i need help of some one so i get information of user when he logins through facebook to my site.

muzammal over 3 years ago

i get error FB.Connect is not a function.
Can you give us the code you are using in leave a comment for facebook log in and log out?!

Timberline over 2 years ago

hi that is me

Amer Alsharif about 1 year ago

test

Pinkesh Soni 9 months ago

Nice post... Thank u...

Quvan Ten 6 months ago

Splendid, to provide a gentleman would claim. Brilliant work on the following writing. I really adore it

Christian Louboutin Shoes about 16 hours ago

Leave a Comment

Name
Email (optional)
Website (optional)
...or login using Facebook to bypass these fields.
Messageusable tags: <b> <i>
Robot?
Loading tweets...
» Christian Louboutin Shoes on Facebook Connect Logout. about 16 hours ago
» Quvan Ten on Facebook Connect Logout. 6 months ago
» Pinkesh Soni on Facebook Connect Logout. 9 months ago
» digital recovery on Relevant Anchor Linking for SEO. about 1 year ago
» data recovery program on HTML5/CSS3 Tutorial: Building a Navigation Menu Without Images. about 1 year ago
» Amer Alsharif on Facebook Connect Logout. about 1 year ago
Site designed, developed and coded by Marc Whitbread ©2011