for some reason today my code for auto login for existed members broke.
normally this code works perfect, after a check with firebug I saw that there is a problem finding ‘auth.login’ for some reason, and therefor the call for window.location.reload(); isn’t working. (if I refresh manually then the member shows as connect properly,the problem is just the auto login before the session is open that need a page refresh)
I also tried to see if the problem is only ‘auto.login’ and replaced it with ‘auth.authResponseChange’ when I did it the page kept on refreshing … so I figure that problem is with ‘auth.login’ trigger.
does anyone knows for a special reason or any change facebook made that could cause this problem?
*update* BUG is solved! this problem was fixed by facebook.
this bug was reported and also answered by facebook here-
https://developers.facebook.com/bugs/524245490930206?browse=search_50f87d9e8869a5e06191882#
BTW,Here is A WORKING AGAIN code:
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '<?php =$APP_ID ?>',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true, // parse XFBML
oauth : true
});
// Additional initialization code here
FB.Event.subscribe('auth.login', function(response) {
window.location.reload();
});
};
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
ref.parentNode.insertBefore(js, ref);
}(document));
</script>
it seems i’m experiencing the same problem ..
Till a few hours ago, when a user (who had already authorized and logged in to my app previously) opened my website and the cookie was expired, the login button appeared but after a few seconds (the time for the JS SDK to trigger the login function), he was automatically logged-in and the page was reloaded without the login button and with the user information.
Now when an already registered user opens my site after cookie expired, the login button appears again, but the user isn’t automatically logged in and the page doesn’t reload like it did before. The strange thing is that if i click on the login button it doesn’t work either! If i now refresh the page manually the login button disappears and user information is displayed, so it seems that the user was actually logged-in but the event was not caught to trigger the page reload.
If i manually log-out and login again (thus using the php sdk) everything works.
My code:
UPDATE I added this few lines to my js code:
So now when the users opens my page after token expired:
(like before)
before)
it for sure now because it pops up the alert: The status of the
session is:connected)
the script isn’t aware of succeeded log in -> the page is not
reloaded