Avoid Race Condition in Facebook JavaScript API with FB.logout
I am desperately trying to force a logout before a user starts a new facebook session. But before logout is succesfully called, auth.login seems to login the user and I redirect them.  So it seems to be a race condition, but I can't figure out how to get around it.

FB.init({appId: xxxx, status: true, cookie: true, xfbml: true});

  //Try to log out user
  FB.logout();

                //Show the FB div
                if(FB) {
                    FB.Event.subscribe('auth.logout', function(response) {
                        // do something with response
                        logout();
                    });
                    FB.getLoginStatus(function(response) {
                        if (response.session) {
                            login(response);
                        }
                    });
                    FB.Event.subscribe('auth.login', function(response) {
                        login(response);
                        //login redirects the user. Before logout fires()
                    });
                   
                } // end if(FB).
Avoid Race Condition in Facebook JavaScript API with FB.logout
===

I am desperately trying to force a logout before a user starts a new facebook session. But before logout is succesfully called, auth.login seems to login the user and I redirect them.  So it seems to be a race condition, but I can't figure out how to get around it.

FB.init({appId: xxxx, status: true, cookie: true, xfbml: true});

  //Try to log out user
  FB.logout();

                //Show the FB div
                if(FB) {
                    FB.Event.subscribe('auth.logout', function(response) {
                        // do something with response
                        logout();
                    });
                    FB.getLoginStatus(function(response) {
                        if (response.session) {
                            login(response);
                        }
                    });
                    FB.Event.subscribe('auth.login', function(response) {
                        login(response);
                        //login redirects the user. Before logout fires()
                    });
                   
                } // end if(FB).