简体   繁体   中英

Is it possible to keep the Facebook session alive?

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

I use the Javascript SDK in conjunction with the PHP SDK and I am finding it very hard to figure out a solution to this.

If the session does not exist then PHP cannot detect the user and therefore my site thinks they have logged out, when in fact, the session has simply expired and they just need to refresh the page to allow the Javascript SDK to regenerate the session. The reason why I need to sort this so desperately is simply because the user will see a page saying that they are not logged in, when in fact they are. All they need to do is refresh the page to send the new session to the PHP SDK

A page refresh via javascript is not a solution here as this happens too frequently and it does not look good loading half a page and then automatically refreshing

Is there anyway around this?

UPDATE

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

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

from Facebook Extended Permissions

Enables your app to perform authorized requests on behalf of the user at any time. By default, most access tokens expire after a short time period to ensure applications only make requests on behalf of the user when the are actively using the application. This permission makes the access token returned by our OAuth endpoint long-lived.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM