protected function getSessionObject($access_token = NULL) {
    $session = NULL;

    // Try generate local version of session cookie.
    if (!empty($access_token) && isset($access_token['access_token'])) {
      $session['access_token'] = $access_token['access_token'];
      $session['base_domain'] = $this->getVariable('base_domain', self::DEFAULT_BASE_DOMAIN);
      $session['expires'] = isset($access_token['expires_in']) ? time() + $access_token['expires_in'] : time() + $this->getVariable('expires_in', self::DEFAULT_EXPIRES_IN);
      $session['refresh_token'] = isset($access_token['refresh_token']) ? $access_token['refresh_token'] : '';
      $session['scope'] = isset($access_token['scope']) ? $access_token['scope'] : '';
      $session['secret'] = md5(base64_encode(pack('N6', mt_rand(), mt_rand(), mt_rand(), mt_rand(), mt_rand(), uniqid())));

      // Provide our own signature.
      $sig = self::generateSignature(
        $session,
        $this->getVariable('client_secret')
      );
      $session['sig'] = $sig;
    }

    // Try loading session from $_REQUEST.
    if (!$session && isset($_REQUEST['session'])) {
      $session = json_decode(
        get_magic_quotes_gpc()
          ? stripslashes($_REQUEST['session'])
          : $_REQUEST['session'],
        TRUE
      );
    }
    
    //Try and get session from file cache
    if(!$session && $this->getVariable('use_file_cache') == TRUE){
        $session = $this->getSessionFromFileCache();  
    }

    return $session;
  }
protected function getSessionObject($access_token = NULL) {
    $session = NULL;

    // Try generate local version of session cookie.
    if (!empty($access_token) && isset($access_token['access_token'])) {
      $session['access_token'] = $access_token['access_token'];
      $session['base_domain'] = $this->getVariable('base_domain', self::DEFAULT_BASE_DOMAIN);
      $session['expires'] = isset($access_token['expires_in']) ? time() + $access_token['expires_in'] : time() + $this->getVariable('expires_in', self::DEFAULT_EXPIRES_IN);
      $session['refresh_token'] = isset($access_token['refresh_token']) ? $access_token['refresh_token'] : '';
      $session['scope'] = isset($access_token['scope']) ? $access_token['scope'] : '';
      $session['secret'] = md5(base64_encode(pack('N6', mt_rand(), mt_rand(), mt_rand(), mt_rand(), mt_rand(), uniqid())));

      // Provide our own signature.
      $sig = self::generateSignature(
        $session,
        $this->getVariable('client_secret')
      );
      $session['sig'] = $sig;
    }

    // Try loading session from $_REQUEST.
    if (!$session && isset($_REQUEST['session'])) {
      $session = json_decode(
        get_magic_quotes_gpc()
          ? stripslashes($_REQUEST['session'])
          : $_REQUEST['session'],
        TRUE
      );
    }
    
    //Try and get session from file cache
    if(!$session && $this->getVariable('use_file_cache') == TRUE){
        $session = $this->getSessionFromFileCache();  
    }

    return $session;
  }
protected function getSessionObject ( $ access_token = NULL ) { $ session = NULL ; // Try generate local version of session cookie.
 if ( ! empty ( $ access_token ) && isset ( $ access_token [ 'access_token' ] ) ) { $ session [ 'access_token' ] = $ access_token [ 'access_token' ] ; $ session [ 'base_domain' ] = $ this -> getVariable ( 'base_domain' , self :: DEFAULT_BASE_DOMAIN ) ; $ session [ 'expires' ] = isset ( $ access_token [ 'expires_in' ] ) ? time ( ) + $ access_token [ 'expires_in' ] : time ( ) + $ this -> getVariable ( 'expires_in' , self :: DEFAULT_EXPIRES_IN ) ; $ session [ 'refresh_token' ] = isset ( $ access_token [ 'refresh_token' ] ) ? $ access_token [ 'refresh_token' ] : '' ; $ session [ 'scope' ] = isset ( $ access_token [ 'scope' ] ) ? $ access_token [ 'scope' ] : '' ; $ session [ 'secret' ] = md5 ( base64_encode ( pack ( 'N6' , mt_rand ( ) , mt_rand ( ) , mt_rand ( ) , mt_rand ( ) , mt_rand ( ) , uniqid ( ) ) ) ) ; // Provide our own signature.
 $ sig = self :: generateSignature ( $ session , $ this -> getVariable ( 'client_secret' ) ) ; $ session [ 'sig' ] = $ sig ; } // Try loading session from $_REQUEST.
 if ( ! $ session && isset ( $ _REQUEST [ 'session' ] ) ) { $ session = json_decode ( get_magic_quotes_gpc ( ) ? stripslashes ( $ _REQUEST [ 'session' ] ) : $ _REQUEST [ 'session' ] , TRUE ) ; } //Try and get session from file cache
 if ( ! $ session && $ this -> getVariable ( 'use_file_cache' ) == TRUE ) { $ session = $ this -> getSessionFromFileCache ( ) ; } return $ session ; }
Try to get session object from custom method.

By default we generate session object based on access_token response, or
if it is provided from server with $_REQUEST. For sure, if it is provided
by server it should follow our session object format.

Session object provided by server can ensure the correct expires and
base_domain setup as predefined in server, also you may get more useful
information for custom functionality, too. BTW, this may require for
additional remote call overhead.

You may wish to override this function with your custom version due to
your own server-side implementation.

@param $access_token
(optional) A valid access token in associative array as below:
- access_token: A valid access_token generated by OAuth2.0
authorization endpoint.
- expires_in: (optional) A valid expires_in generated by OAuth2.0
authorization endpoint.
- refresh_token: (optional) A valid refresh_token generated by OAuth2.0
authorization endpoint.
- scope: (optional) A valid scope generated by OAuth2.0
authorization endpoint.

@return
A valid session object in associative array for setup cookie, and
NULL if not able to generate it with custom method.
Try to get session object from custom method .