I have a strange problem, I have a logout link that displays only if the user is logged in. I have this code inside the the onclick event of this link (using a function):
FB.logout();
window.location = 'http://www.google.com';
If I click on this once, nothing happens, I know that the function gets executed because I've tested this with an alert. However, if I click on it a second time, the page reloads itself and the user is indeed logged out. The page is never directed to google.com, so the function never gets as far as the window.location part.
I have the window.location because I thought that if I could refresh the page using window.location.refresh once the logout is complete that it would successfully log the user out. However, if anybody has any other techniques on how to logout the user out of facebook, I would love to hear them! I've attempted to manually delete the cookie, but that didn't work, the cookie still existed for some reason. I've also tried this:
FB.logout(function(response) {
window.location = 'http://www.google.com';
});
I know a callback like this is possible because of the documentation:
http://developers.facebook.com/docs/reference/javascript/FB.logout
Has anybody else had this issue before? Any advice would help thanks!
UPDATE: After some debugging I've found out that if I click the link once. Then manually refresh the page it logs the user out.