I have third party cookies enabled so that's not the problem. I'm using google Chrome, facebook javascript SDk version 2.5, everything is working the first time when I login, but when I log out and try to log back in, it's returning status: 'unknown'
3 Answers
I too faced this problem in Chrome. However, in Firefox it worked as expected with the status returned as connected when the user had logged in previously.
The root cause of this issue is, on FB.logout(), Chrome is not removing the cookie fblo_<your-app-id> which is somehow affecting FB.getLoginStatus() function to return unknown
Fix: On calling FB.logout(), you may programmatically delete the cookie fblo_<your-app-id>
FB.logout(function(response) {
deleteCookie("fblo_" + fbAppId); // fblo_yourFBAppId. example: fblo_444499089231295
});
function deleteCookie(name) {
document.cookie = name +'=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';
}
I have a similar issue after logout. It appears that FB.logout() creates a fblo_<your-app-id> cookie that has an expiration date of 1 year and it never goes away, not even after you log in again. It also seems that this particular cookie then obstructs FB.getLoginStatus() from returning a proper status in certain cases. Deleting the cookie manually fixes things, but I can't say why it's not being deleted automatically by successful FB.login() call