Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5948693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:08:39+00:00 2026-05-22T17:08:39+00:00

with the old (2.x) SDK I used this to log someone with offline_access: $session

  • 0

with the old (2.x) SDK I used this to log someone with offline_access:

$session = array
(
    'uid' => $userdata['fb_uid'],
    'sig' => $userdata['fb_sig'],
    'access_token' => $userdata['fb_access_token']
);

$facebook->setSession($session);

In the new SDK this function doesnt exist anymore. I think I need to login using:

setPersistentData($key, $value)

but this function is protected and I dont know what ‘code’ is? Do I need this to log the user in or not? And what’s going on with ‘sig’? Don’t I need this anymore?

Hope someone already figured this out because the documentation really doesn’t help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T17:08:40+00:00Added an answer on May 22, 2026 at 5:08 pm

    With the Facebook PHP SDK v3 (see on github), it is pretty simple. To log someone with the offline_access permission, you ask it when your generate the login URL. Here is how you do that.

    Get the offline access token

    First you check if the user is logged in or not :

    require "facebook.php";
    $facebook = new Facebook(array(
        'appId'  => YOUR_APP_ID,
        'secret' => YOUR_APP_SECRET,
    ));
    
    $user = $facebook->getUser();
    
    if ($user) {
      try {
        $user_profile = $facebook->api('/me');
      } catch (FacebookApiException $e) {
        // The access token we have is not valid
        $user = null;
      }
    }
    

    If he is not, you generate the “Login with Facebook” URL asking for the offline_access permission :

    if (!$user) {
        $args['scope'] = 'offline_access';
        $loginUrl = $facebook->getLoginUrl($args);
    }
    

    And then display the link in your template :

    <?php if (!$user): ?>
        <a href="<?php echo $loginUrl ?>">Login with Facebook</a>
    <?php endif ?>
    

    Then you can retrieve the offline access token and store it. To get it, call :

    $facebook->getAccessToken()
    

    Use the offline access token

    To use the offline access token when the user is not logged in :

    require "facebook.php";
    $facebook = new Facebook(array(
        'appId'  => YOUR_APP_ID,
        'secret' => YOUR_APP_SECRET,
    ));
    
    $facebook->setAccessToken("...");
    

    And now you can make API calls for this user :

    $user_profile = $facebook->api('/me');
    

    Hope that helps !

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The old JS SDK had a function called FB.ensureInit. The new SDK does not
Say i have this old manuscript ..What am trying to do is making the
I want to write SDK using Visual C++ 2010, which can be used by
I had code in a old sdk 3.0 project of mine that is not
I'm using a new work computer that has an old sdk, Java 1.3.1, on
I'm using the old Rest API (and old Javascript SDK) to develop an iframe
[ Old question title used to be ARC is set to YES, but xcode
I have an old app I made for myself that I haven't used in
I am using the old facebook iphone sdk to develop a iphone app: https://github.com/megastep/facebook-iphone-sdk
I've been using the old v3.0 C# SDK for some time and Facebook have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.