Can I keep my Facebook session alive?

I found that after a certain time, the Facebook session created using the Javascript SDK expires. I appreciate that a session cannot live forever, but is there a way for a user to enter my site indefinitely, unless, of course, they log out of Facebook?

I use the Javascript SDK in conjunction with the PHP SDK, and it is very difficult for me to find a solution for this.

If the session does not exist, PHP cannot detect the user, so my site believes that he logged out when the session actually just expired, and they just need to refresh the page to allow the Javascript SDK to restore the session. The reason I need to take this away so desperately is simply because the user will see a page that says they are not logged in when they really are. All they need to do is refresh the page to send a new session to the PHP SDK

Updating a page using javascript is not a solution here, as it happens too often, and it doesnโ€™t look very good, loading half the page and then automatically refreshing

Anyway?

UPDATE

I found an article that refers to what is called 'offline_access', could this be the answer? Can I still post things using this?

+4
source share
1 answer

Use the offline_access permission to extend the validity of your access tokens and thereby make your sessions live forever (or until it expires in May).

from Advanced Permissions for Facebook

Allows your application to complete authorized requests on behalf of the user at any time. By default, most access tokens expire after a short period of time to ensure that applications only execute requests on behalf of the user when they actively use the application. This permission makes the access token returned by our OAuth endpoint durable.

+2
source

Source: https://habr.com/ru/post/1396501/


All Articles