I\'m following this guide: https://developers.facebook.com/docs/howtos/login/getting-started/
Everything is working fine with regards to the login. What I don\'t underst
I guess FB.getLoginStatus is used instead of sessions?
FB.getLoginStatus is used to help you optimize your visitors experience based on their login status and hence it's not a replacement of "sessions".
I have to check FB.getLoginStatus everytime the user enters a new page in my website. Does that mean i have to initialize the JavaScript SDK for every page? Thats 50 lines of code for every page just to check the login status...
Well, initializing the Javascript SDK is something you have to do if you wish to use the SDK. Now I don't see anything wrong with the numbers of lines of code, as Facebook already loads the SDK asynchronously and hence it won't block your page resources.
And for your first point, you don't have to call FB.getLoginStatus every time on page load and Facebook already states this in the related document:
While you can call
FB.getLoginStatusany time (for example, when the user tries to take a social action), most social apps need to know the user's status as soon as possible after the page loads. In this case, rather than callingFB.getLoginStatusexplicitly, it is possible to check the user's status by settingstatus: truewhen you callFB.init.To receive the response of this call, you must subscribe to the
auth.statusChangeevent. The response object passed by this event is identical to that which would be returned by callingFB.getLoginStatusexplicitly.
Now one thing that you might have missed, is the PHP-SDK:
The Facebook SDK for PHP can work in conjunction with the Facebook SDK for Javascript to provide seamless session management across both the client and server-sides of an app.
This would make your life easier as you would have an idea of the user status upon (before) loading the page and hence customize the user experience accordingly and then wait for any status change triggered by the Javascript SDK.
From the Facebook Developers area it seems they have a section on how to login without calling their Javascript SDK.
https://developers.facebook.com/docs/howtos/login/client-side-without-js-sdk/
The user will have an API access token which can be used for further requests.
I hope that helps.