I'm struggling to keep a Facebook session using PHP on my website.
I use both the JavaScript SDK and the PHP SDK to form the basis of my application.
The problem I am facing is that when the "Facebook session" ends, my PHP script considers that you are logged out of Facebook. But, as soon as I call FB.init() using the JavaScript SDK, the session will come back to life.
Is there anyway to achieve the same using the PHP SDK? Or can I set a custom expiration time on a Facebook session?
Extracted from comments
It seems that the session expiration time is set to 2 hours, but I'm not sure about that. I do not think that calling a PHP api will matter. I need to clarify a little what is happening. Basically, if you come to my homepage, you will be able to log in via Facebook. If you do, everything will be fine! Once you are logged in and you have authorized the application, this is normal until the session ends. When the session expires, it seems that the PHP SDK cannot determine if you are registered through Facebook, however, the Javascript SDK. I am using getUser () for the PHP SDK.
In other words, since the session has expired, PHP thinks you are no longer logged in via Facebook. The Javascript SDK is able to determine if you are registered or not, regardless of whether the session exists. When he realizes that this is so, he recreates the session in any way. But in order for the session to be picked up by PHP, the page obviously needs to be updated. This is the problem that I have, since the page displays content based on your Facebook login, I need the PHP SDK to be able to recreate the session, so there is no need to refresh the page.
source share