When someone closes the browser or log out of facebook, the php sdk should detect the problem and automatically destroy the session, but it doesnt seems to be the case, even when we call $fb->destroySession();
One way to effectively check for problem is to use Facebook javascript sdk by subscribing to :
----------
FB.Event.subscribe('auth.logout', function(response) {
if (response.status=="unknown") {
//some weird session error
document.location.href="login.php";
return;
}
doTimerReload();
});
----------
The code effectively detect the logout with "unknown" status and redirect the user to a login screen.
Example of a login.php code:
Please <a href="javascript:">click here</a><br /> <script>
function doFBLogin() {
FB.login(function(response) {
if (response.authResponse) {
FB.api('/me', function(response) {
});
} else {
alert("Please authorize app by refreshing to continue...");
}
}, {scope: 'email,user_likes'}); //additional parameter
}
</script><br />
----------
No comments:
Post a Comment