library/Garp/3rdParty/facebook/src/base_facebook.php
protected function getUserFromAvailableData() {
    // if a signed request is supplied, then it solely determines
    // who the user is.
    $signed_request = $this->getSignedRequest();
    if ($signed_request) {
      if (array_key_exists('user_id', $signed_request)) {
        $user = $signed_request['user_id'];

        if($user != $this->getPersistentData('user_id')){
          $this->clearAllPersistentData();
        }

        $this->setPersistentData('user_id', $signed_request['user_id']);
        return $user;
      }

      // if the signed request didn't present a user id, then invalidate
      // all entries in any persistent store.
      $this->clearAllPersistentData();
      return 0;
    }

    $user = $this->getPersistentData('user_id', $default = 0);
    $persisted_access_token = $this->getPersistentData('access_token');

    // use access_token to fetch user id if we have a user access_token, or if
    // the cached access token has changed.
    $access_token = $this->getAccessToken();
    if ($access_token &&
        $access_token != $this->getApplicationAccessToken() &&
        !($user && $persisted_access_token == $access_token)) {
      $user = $this->getUserFromAccessToken();
      if ($user) {
        $this->setPersistentData('user_id', $user);
      } else {
        $this->clearAllPersistentData();
      }
    }

    return $user;
  }
protected function getUserFromAvailableData() {
    // if a signed request is supplied, then it solely determines
    // who the user is.
    $signed_request = $this->getSignedRequest();
    if ($signed_request) {
      if (array_key_exists('user_id', $signed_request)) {
        $user = $signed_request['user_id'];

        if($user != $this->getPersistentData('user_id')){
          $this->clearAllPersistentData();
        }

        $this->setPersistentData('user_id', $signed_request['user_id']);
        return $user;
      }

      // if the signed request didn't present a user id, then invalidate
      // all entries in any persistent store.
      $this->clearAllPersistentData();
      return 0;
    }

    $user = $this->getPersistentData('user_id', $default = 0);
    $persisted_access_token = $this->getPersistentData('access_token');

    // use access_token to fetch user id if we have a user access_token, or if
    // the cached access token has changed.
    $access_token = $this->getAccessToken();
    if ($access_token &&
        $access_token != $this->getApplicationAccessToken() &&
        !($user && $persisted_access_token == $access_token)) {
      $user = $this->getUserFromAccessToken();
      if ($user) {
        $this->setPersistentData('user_id', $user);
      } else {
        $this->clearAllPersistentData();
      }
    }

    return $user;
  }
protected function getUserFromAvailableData ( ) { // if a signed request is supplied, then it solely determines // who the user is. $ signed_request = $ this -> getSignedRequest ( ) ; if ( $ signed_request ) { if ( array_key_exists ( 'user_id' , $ signed_request ) ) { $ user = $ signed_request [ 'user_id' ] ; if ( $ user != $ this -> getPersistentData ( 'user_id' ) ) { $ this -> clearAllPersistentData ( ) ; } $ this -> setPersistentData ( 'user_id' , $ signed_request [ 'user_id' ] ) ; return $ user ; } // if the signed request didn't present a user id, then invalidate // all entries in any persistent store. $ this -> clearAllPersistentData ( ) ; return 0 ; } $ user = $ this -> getPersistentData ( 'user_id' , $ default = 0 ) ; $ persisted_access_token = $ this -> getPersistentData ( 'access_token' ) ; // use access_token to fetch user id if we have a user access_token, or if // the cached access token has changed. $ access_token = $ this -> getAccessToken ( ) ; if ( $ access_token && $ access_token != $ this -> getApplicationAccessToken ( ) && ! ( $ user && $ persisted_access_token == $ access_token ) ) { $ user = $ this -> getUserFromAccessToken ( ) ; if ( $ user ) { $ this -> setPersistentData ( 'user_id' , $ user ) ; } else { $ this -> clearAllPersistentData ( ) ; } } return $ user ; }
Determines the connected user by first examining any signed
requests, then considering an authorization code, and then
falling back to any persistent store storing the user.

@return integer The id of the connected Facebook user,
or 0 if no such user exists.
Determines the connected user by first examining any signed requests then considering an authorization code and then falling back to any persistent store storing the user .