I am using fb connect using js. This is my code:
Method 1:
Though I believe that DMCS has given a correct solution to the problem, here is another way to approach. Use FB.login method with a custom login link.
Body markup:
Login with Facebook
When you click on the button, it will run the callback function inside FB.login.
Method 2:
Alternatively, using FB login button plugin, you can subscribe to auth.statusChange and check for the status of the user in response.
FB.Event.subscribe('auth.statusChange', function(response) {
// check for status in the response
});
Note if you are using fb login button plugin, and the user is already logged in and connected to the app, no login button is shown (read it in the documentation here)