since all the changes facebook made in the past year lot of things are changed. there are some solutions over the web but they do not work any more. (LIKE THIS ONE: Using the PHP or JavaScript Facebook SDK, how can I keep the user logged in to my website?)
I have implemented facebook connect with PHP facebook SDK on my website. the problem is with users that already approved my App and that also logged in to their facebook. In this case I want them the auto login with no need to press the connect button again. I guess that there is a way to do it using php+js but I couldn't find how and believe me I tried several things. the problem is that the php user check
$user = $facebook->getUser();
doesn't recognized facebook session and I think that maybe I can trigger it with JS. so I tired adding this code for the page in JS and the ALRETS are working saying user is connected but NO session pass to PHP, so PHP SDK doesn't recognize user is connected :
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '<?=FACEBOOK_APP_ID?>',
status : true, //
cookie : true, //
xfbml : true, //
oauth : true
});
// Additional initialization code here
//--------> this isn't need to work its only a check
FB.getLoginStatus( function(response) {
//console.log(response);
if (response.status === 'connected') {
var accessToken = response.authResponse.accessToken;
alert(accessToken);
} else if (response.status === 'not_authorized') {
//login function
} else {
//login function
}
}, true);
FB.Event.subscribe('auth.authResponseChange', function(response) {
//console.log('The status of the session changed to: '+response.status);
alert(response.status);
});
//--------> END OF CHECK!!
};
// 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/<?=$fb_api_lang?>/all.js#xfbml=1";
ref.parentNode.insertBefore(js, ref);
}(document));
</script>
if anyone found a solution for this problem and could share it will be much appreciated.