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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:59:08+00:00 2026-05-17T18:59:08+00:00

I think if we make calls to Facebook using REST or Graph API, we

  • 0

I think if we make calls to Facebook using REST or Graph API, we will know if it is fake because it will come back saying fake session / auth_token / access_token. But what if we are showing our own DB info, such as the user’s “most preferred product list”, then we don’t make any call to Facebook but show our DB’s data. How do we know it is really the user, not somebody faking the cookie?

  • 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-17T18:59:08+00:00Added an answer on May 17, 2026 at 6:59 pm

    When you read a cookie with facebook it contains a value called ‘sig’. With this value, the other cookie values, and your app secret you hash the contents of the cookie and validate it against the sig. If they match, then the cookie is valid. You can trust this result because only you and Facebook have access to the app secret. Here is the example of how Facebook’s PHP SDK does it. Any respectable Facebook SDK will do this all for you internally.

    /**
       * Validates a session_version=3 style session object.
       *
       * @param Array $session the session object
       * @return Array the session object if it validates, null otherwise
       */
      protected function validateSessionObject($session) {
        // make sure some essential fields exist
        if (is_array($session) &&
            isset($session['uid']) &&
            isset($session['access_token']) &&
            isset($session['sig'])) {
          // validate the signature
          $session_without_sig = $session;
          unset($session_without_sig['sig']);
          $expected_sig = self::generateSignature(
            $session_without_sig,
            $this->getApiSecret()
          );
          if ($session['sig'] != $expected_sig) {
            self::errorLog('Got invalid session signature in cookie.');
            $session = null;
          }
          // check expiry time
        } else {
          $session = null;
        }
        return $session;
      }
    

    Here is the same thing in C# (Facebook C# SDK):

     /// <summary>
        /// Validates a session_version=3 style session object.
        /// </summary>
        /// <param name="session">The session to validate.</param>
        protected override void ValidateSessionObject(FacebookSession session)
        {
            if (session == null)
            {
                return;
            }
    
            var signature = this.GenerateSignature(session);
            if (session.Signature == signature.ToString())
            {
                return;
            }
    
            session = null;
        }
    
        /// <summary>
        /// Generates a MD5 signature for the facebook session.
        /// </summary>
        /// <param name="session">The session to generate a signature.</param>
        /// <returns>An MD5 signature.</returns>
        /// <exception cref="System.ArgumentNullException">If the session is null.</exception>
        /// <exception cref="System.InvalidOperationException">If there is a problem generating the hash.</exception>
        protected override string GenerateSignature(FacebookSession session)
        {
            var args = session.Dictionary;
            StringBuilder payload = new StringBuilder();
            var parts = (from a in args
                         orderby a.Key
                         where a.Key != "sig"
                         select string.Format(CultureInfo.InvariantCulture, "{0}={1}", a.Key, a.Value)).ToList();
            parts.ForEach((s) => { payload.Append(s); });
            payload.Append(this.ApiSecret);
            byte[] hash = null;
            using (var md5 = System.Security.Cryptography.MD5CryptoServiceProvider.Create())
            {
                if (md5 != null)
                {
                    hash = md5.ComputeHash(Encoding.UTF8.GetBytes(payload.ToString()));
                }
            }
    
            if (hash == null)
            {
                throw new InvalidOperationException("Hash is not valid.");
            }
    
            StringBuilder signature = new StringBuilder();
            for (int i = 0; i < hash.Length; i++)
            {
                signature.Append(hash[i].ToString("x2", CultureInfo.InvariantCulture));
            }
    
            return signature.ToString();
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What do you think - which functions should be implemented to make work with
I think most people know how to do this via the GUI (right click
I think I know how to handle this case, but I just want to
I've done many web apps where the first thing you do is make a
I think the file that is produced is an .asm file, any idea how
I think most people here understand the importance of fully automated builds. The problem
I think this is specific to IE 6.0 but... In JavaScript I add a
I think it can be done by applying the transformation matrix of the scenegraph
I think that java executables (jar files) are trivial to decompile and get the
I think I've got it down to the most basic case: int main(int argc,

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.