function fb_api_check_session in Drupal for Facebook 7.3
Same name and namespace in other branches
- 5.2 fb.module \fb_api_check_session()
- 6.3 fb.module \fb_api_check_session()
- 6.2 fb.module \fb_api_check_session()
Sometimes calls to fb_api_init succeed, but calls to the client api will fail because cookies are obsolete or what have you. This function makes a call to facebook to test the session. Expensive, so use only when necessary.
3 calls to fb_api_check_session()
- fb_devel_info in ./
fb_devel.module - fb_user_user_logoutXXX in ./
fb_user.module - Implements hook_user_logout.
- _fb_user_check_session in ./
fb_user.module - 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.
File
- ./
fb.module, line 961 - This is the core required module of Drupal for Facebook.
Code
function fb_api_check_session($fb) {
$success = FALSE;
try {
$me = $fb
->api('me');
// Store the locale if set.
if (isset($me['locale'])) {
$_SESSION['fb_locale'] = $me['locale'];
}
// Does not matter what is returned, as long as exception is not thrown.
$success = TRUE;
} catch (Exception $e) {
if (fb_verbose()) {
watchdog('fb', 'fb_api_check_session failed. Possible attempt to spoof a facebook session!');
//watchdog('fb', print_r($fb->getSession(), 1));
}
$success = FALSE;
if (fb_verbose()) {
fb_log_exception($e, t("fb_api_check_session failed."));
}
$app_id = $fb
->getAppId();
unset($_SESSION['fb'][$app_id]);
unset($_SESSION['_fb_' . $app_id]);
unset($_SESSION['_fb_token_' . $app_id]);
// Unsetting the javasript fbu can be helpful when third-party cookies disabled.
//fb_js_settings('fbu', 0); @TODO still needed? helpful?
}
return $success;
}