How to generate facebook infinite session

When developing facebook applications, we might need an infinite session that will enable us to update the app users’ profile periodically. For instance, a “Quote Of TheDay” application needs to update its users’ profile everyday with a new quote.

Here are the steps to generate an infinite session that does not expire. Note: these steps only need to be done by the developer once; no action is needed from the app users.

  • Login to your own facebook account.
  • Browse to: http://www.facebook.com/code_gen.php?v=1.0&api_key=YOUR_API_KEY (replace YOUR_API_KEY with your app’s API key) Click through the simple instructions on the page. After that, you’ll be provided with a one-time code like 5P4I8D .
  • Invoke facebook API auth.getSession using the one-time code. The returned result will be the infinite session key.

Source of info: http://wiki.developers.facebook.com/index.php/Authentication_guide

Leave a Reply