E
E
EVOSandru62016-09-08 13:10:02
JavaScript
EVOSandru6, 2016-09-08 13:10:02

Is it possible to fully logout in the facebook api javascript from the application and from the system at once?

Good afternoon,
Created a WEB application in the FACEBOOK API. Made it public.
Connected API:

window.onload = function(){
            window.fbAsyncInit = function() {
                FB.init({
                    appId      : '*****',
                    xfbml      : true,
                    version    : 'v2.7'
                });
            };
        }
        (function(d, s, id){
            var js, fjs = d.getElementsByTagName(s)[0];
            if (d.getElementById(id)) {return;}
            js = d.createElement(s); js.id = id;
            js.src = "//connect.facebook.net/ru_RU/sdk.js";
            fjs.parentNode.insertBefore(js, fjs);
        }(document, 'script', 'facebook-jssdk'));

The site has 2 buttons.
<button id="log_in_fb">Auth FB</button>
      <button id="log_out_fb">Log out FB</button>

jquery code:
$('#log_in_fb').click(function(){
        FB.getLoginStatus(function(response) {
            if(response.status === 'connected') {
                console.log('Logged In');
                var uid = response.authResponse.userID;
                var accessToken = response.authResponse.accessToken;
            }
            else{
                FB.login(function (response){
                    if(response.status === 'connected') {
                        console.log('Авторизован везде');
                    }
                    else if (response.status === 'not_authorized') {
                        console.log('Пользователь авторизован в Facebook, но не авторизован в приложениии')
                    } else {
                        console.log('Пользователь не авторизован в Facebook.')
                    }
                }, { scope : 'public_profile, email, user_friends' });
            }
        });
    });
    $('#log_out_fb').click(function(){
        FB.getLoginStatus(function(response) {
            console.log(response.status);
            if (response && response.status === 'connected') {
                FB.logout(function(response) {
                    console.log('logout');
                });
            }
        });
    });

The scheme is like this.
If I log out of my Facebook account, then when I click on the authorization button on the site, a window appears with a form for entering a login and password. I log in, I agree, the window disappears.
If I press exit, then the first time I press response.status gives connected , the second time it returns unknown . Those. it seems like logout is happening. But again by clicking on the login button - the window pops up and disappears abruptly (my cant?!). I check on the FACEBOOK website. The user session is alive , no logout has occurred

Sadly - cookies cannot be deleted from the browser with javascript (
To the extreme - maybe php can do this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Philipp, 2016-11-17
@zoonman

I recommend not dwelling on the moment you log out of Facebook. This is a different site that has nothing to do with yours.
Logout is described here https://developers.facebook.com/docs/reference/jav ...
You can try opening https://www.facebook.com/logout.php in a hidden iframe to kick the Facebook session out of the browser. Not the prettiest solution, but should work.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question