You are here

function fb_connect_session_start_cb in Drupal for Facebook 6.2

Session start callback.

This can be invoked when a user is logging into facebook connect. If the user was previously logged into Drupal. An authmap entry will be made linking the two accounts.

1 string reference to 'fb_connect_session_start_cb'
fb_connect_menu in ./fb_connect.module
Implementation of hook_menu().

File

./fb_connect.module, line 78
Support for Facebook Connect features

Code

function fb_connect_session_start_cb() {
  global $_fb, $_fb_app;
  global $user;
  if (fb_verbose() == 'extreme') {
    watchdog('fb_connect', t("fb_connect_session_start_cb, session_name is " . session_name() . ", session_id is " . session_id()));
  }

  //watchdog('fbc_authmap_cb', dprint_r($_REQUEST, 1)); // debug
  if ($_fb_app->apikey == $_REQUEST['apikey']) {

    // http://wiki.developers.facebook.com/index.php/Verifying_The_Signature
    if ($fbu = $_fb
      ->get_loggedin_user()) {
      if (function_exists('_fb_user_set_authmap')) {
        _fb_user_set_authmap($_fb_app, $fbu, $user);
      }
    }
  }
  session_destroy();

  // Destroy local drupal session, not session controlled by facebook cookies.
  $user = drupal_anonymous_user();
  drupal_json(TRUE);
  exit;
}