Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook logout button and redirect after logout

I use this code

<fb:login-button autologoutlink="true" perms="user_likes" size="large"></fb:login-button>

to create a login/logout fb button. Everything works, after the login, the login button become a logout button. But If the user click on the logout button, the current page is not refreshed and so all the things that should appear only when the user is authenticated are still there until a manual page refresh is done.

This doesn't happen if I get the logout url (Javascript SDK)

$logoutUrl = $facebook->getLogoutUrl();

and then implement a logout button myself; in that case a proper "next" parameter (with the url of the current page) is passed and the current page is reloaded.

I still would like to use the first solution, is it possible to make it use the "next" parameter?

like image 409
Eugenio Avatar asked Jan 26 '11 11:01

Eugenio


People also ask

How do I redirect after logout?

To redirect the user after they log out from a specific application, you must add the URL used in the returnTo parameter of the redirect URL to the Allowed Logout URLs list in the Settings tab of your Auth0 application that is associated with the CLIENT_ID parameter.

What is the logout link for Facebook?

Tap in the top right of Facebook. Scroll to the bottom and tap Log Out. If you've logged into your Facebook account on multiple devices, you'll need to log out of each device separately.


1 Answers

Do the redirect yourself - add this to JavaScript, somewhere after FB.init():

<script>
  FB.Event.subscribe("auth.logout", function() {window.location = '/logout'});
</script>

This function will fire when logout through the FB button happens.

like image 81
Piskvor left the building Avatar answered Oct 21 '22 08:10

Piskvor left the building