getLoginStatus returns status unknown when trying to logout from Facebook using Facebook JS SDK

删除回忆录丶 提交于 2019-12-04 06:54:44

It seems that there's a bug currently in the FB.logout function. After calling it the user can not be logged into this App again using the JS SDK because the FB.login function returns
Object { status="unknown", authResponse=null}

EDIT:
Found that there's a cookie called "fblo_*" created after FB.logout() which seems to be the reason for this. I can't say exactly why it's there and what it does, but deleting it makes the login work again.

Therefor I created a small script that looks for this cookie and deletes it just before I call FB.login() which you probably want to call in a click event (https://developers.facebook.com/docs/reference/javascript/FB.login/v2.5).

function delete_cookie(name) 
{
    document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT; path=/';
}


var cookies = document.cookie.split(";");
for (var i = 0; i < cookies.length; i++)
{
    if(cookies[i].split("=")[0].indexOf("fblo_") != -1)
        delete_cookie(cookies[i].split("=")[0]);
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!