You are here

function _fb_user_check_session in Drupal for Facebook 7.3

Same name and namespace in other branches
  1. 6.3 fb_user.module \_fb_user_check_session()

Test facebook session by calling into facebook. This is expensive, so limit check to once per session. Use session variable to flag that we have completed the test.

1 call to _fb_user_check_session()
_fb_user_process_authorized_user in ./fb_user.module
Create local account or account map for a facebook user who has authorized the application.

File

./fb_user.module, line 316
This module manages relations between local Drupal user accounts and their accounts on facebook.com.

Code

function _fb_user_check_session($fbu) {

  // Make sure facebook session is valid and fb_user table is correct.
  // Relatively expensive operations, so we perform them only once per session.
  if (!isset($_SESSION['fb_user_fbu']) || $_SESSION['fb_user_fbu'] != $fbu) {
    if ($valid_session = fb_api_check_session($GLOBALS['_fb'])) {

      // Expensive check.
      $_SESSION['fb_user_fbu'] = $fbu;
    }
    else {
      unset($_SESSION['fb_user_fbu']);
    }
  }
  return isset($_SESSION['fb_user_fbu']) && $_SESSION['fb_user_fbu'] == $fbu;
}