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 6021383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:42:17+00:00 2026-05-23T03:42:17+00:00

I am using Facebook PHP SDK 3.0 I would like to know how could

  • 0

I am using Facebook PHP SDK 3.0

I would like to know how could I store the session of the user in the database so that once the user provides access and logs in, I could store the access tokens in the database and use it next time so that the user doesn’t require to log in again. Right now I am using the following code

 $facebook = new Facebook(array(
            'appId' => APP_ID,
            'secret' => SECRET,
            'cookie' => true
            ));
        $user = $facebook->getUser();

         if(!$user)
        {
             $loginUrl = $facebook->getLoginUrl();

             echo anchor($loginUrl,"login");
        }

        //print_r($_SESSION);
        $user = $facebook->getUser();

        if($user)
        {
            try 
            {
                // Proceed knowing you have a logged in user who's authenticated.
                $user_profile = $facebook->api('/me');
                //print_r($user_profile);
            } 
            catch (FacebookApiException $e) 
            {
                error_log($e);
                $user = null;
            }
        }

Any help appreciated thanks

  • 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-23T03:42:18+00:00Added an answer on May 23, 2026 at 3:42 am

    Facebook access keys expire after a while. Even if you do store them, and they have not expired yet, they will not work if the user is not logged in. If you want to access the users Facebook account while the user is offline, you need the ‘offline_access’ permmission.

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

Sidebar

Related Questions

I would like to know how to add a picture to an event using
I am using the PHP library for the Graph API ( http://github.com/facebook/php-sdk ) but
I have downloaded php-sdk for using facebook in php. I also created facebook application
I'm using the Facebook php-sdk to get the users name and friends, right now
I'm using the facebook graph PHP sdk - whenever I call the $facebook->api method
I would like to upload a photo to facebook for a user in the
I am using facebook PHP SDK to access the friend list include_once(../fb-config.php); include_once(../facebook.php); try{
Using C#, I need a class called User that has a username, password, active
I would like to embed a flash file into my facebook iframe canvas, I
I'm having problems trying to connect my website to Facebook. What I would like

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.