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.

References: http://wiki.developers.facebook.com/index.php/Authentication_guide

4 Responses to “How to generate facebook infinite session”

  1. Murali Says:

    Hi.

    I need to know how disable the infinite session on the application.Because my app has seperate login inside the app.Due to the infinite session i one use logged in the system then loggged out .If another user logged into the app it shows session values of previous user.Please help me this issue as soon as possible

  2. singchyun Says:

    Hi Murali,

    I’m not exactly sure what you’re trying to describe. But in case it’s of any help to you, Facebook infinite sessions are always disabled unless you explicitly enable them.

  3. Emmanuel Crouvisier Says:

    Here’s a more thorough explanation that I just finished writing up, as well as how to use the acquired infinite session key. Hope it helps!

    http://www.emcro.com/blog/2009/01/facebook-infinite-session-keys-no-more/

  4. links for 2009-04-09 | Nathan and his Open Ideals Says:

    [...] How to generate facebook infinite session « Tech Notes @ Fernvale 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. (tags: api facebook sessions social) Share and Enjoy: [...]

Leave a Reply