I’ve been doing a Facebook Connect implementation using CakePHP and was having no luck using the fb.connect.logout function. I’m not sure whether this qualifies as a bug (dodgy code) or just a case of RTFM (or look at the examples closely) but I simply couldn’t get the fb.connect.logout function to log me out of Facebook and consequently my own application.
Testing a few combinations the on
<a href=”/users/logout” onclick=”FB.Connect.logout(logoutCallback())”>Logout</a>
(who’s logic I found here http://developers.facebook.com/docs/?u=facebook.jslib.FB.Connect.logout)
simply didn’t work. The function was called as was the callback but it simply didn’t log out of Facebook.
The only way I could get it to work was using the logoutAndRedirect function instead, using the following:
<a href=”#” onclick=”FB.Connect.logoutAndRedirect(‘/users/logout’)”>Logout</a>
NOTE: Originally I had put a value in the href attribute (“/users/logout” thinking it would degrade nicely) but this stopped the main function from working, so as far as I can tell you must have a # symbol in the href.