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'
- 4,376
- 8
- 37
- 62
-
1Might be the same issue as here: https://developers.facebook.com/bugs/1657864107810379/ – CBroe Jan 13 '16 at 09:52
-
In my case i switched the allowed URI's and got this message. Deleting the cookies solved the problem. – hypnomaki Dec 21 '16 at 19:58
3 Answers
Use the following code after logout to resolve the issue:
document.cookie.split(";").forEach(function(c) {
document.cookie = c.replace(/^ +/, "").replace(/=.*/, "=;expires=" + new Date().toUTCString() + ";domain=.example.com;path=/");
});
Replace example.com with your domain name.
- 9,564
- 146
- 81
- 122
- 296
- 1
- 3
- 10
-
-
1except this deletes ALL your cookies for the domain. Probably not a good idea! Look at @nagesh answer instead. Makes much more sense – Simon_Weaver Dec 04 '17 at 06:44
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;';
}
- 432
- 6
- 12
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
- 4,285
- 5
- 31
- 30