$value) { if ($pos = strpos($key, '_session_key')) { $apikey = substr($key, 0, $pos); $session_key = $value; break; } } if (isset($apikey)) { fb_settings(FB_SETTINGS_APIKEY, $apikey); fb_settings(FB_SETTINGS_SESSION_KEY, $session_key); fb_settings(FB_SETTINGS_TYPE, FB_SETTINGS_TYPE_CONNECT); } } } // By default Drupal will name the session based on the $cookie_domain. // When facebook controls the session, we need a different name. if (!isset($_REQUEST['fb_session_no']) && // (a way to override this) fb_settings(FB_SETTINGS_APIKEY) && fb_settings(FB_SETTINGS_TYPE)) { // Set session name differently for each app. //session_name('SESS' . fb_settings(FB_SETTINGS_TYPE) . md5(fb_settings(FB_SETTINGS_APIKEY))); // not sufficient! // In fb connect, one user may log out of facebook, and another log in // using same browser. We never get a logout event! For this case we must // make session names different. session_name('SESS' . fb_settings(FB_SETTINGS_TYPE) . md5(fb_settings(FB_SETTINGS_APIKEY) . fb_settings(FB_SETTINGS_SESSION_KEY))); // unique to session, if known. if (fb_settings(FB_SETTINGS_TYPE) == FB_SETTINGS_TYPE_CANVAS && fb_settings(FB_SETTINGS_SESSION_KEY)) { // Spoof a cookie, and make it the same for both FBML and iframe canvas pages. $session_id = 'fb_canvas_' . md5(fb_settings(FB_SETTINGS_APIKEY) . fb_settings(FB_SETTINGS_SESSION_KEY)); session_id($session_id); $_COOKIE[session_name()] = $session_id; fb_settings('fb_session_id_force', $session_id); } } // Also disable Drupal's caching, because a 'connected' user is not truly anonymous. if (fb_settings(FB_SETTINGS_SESSION_KEY)) { $GLOBALS['conf']['cache'] = 0; } } // We will use session names to ensure a unique session for // facebook-controlled sessions. That is we will keep our cookies seperate // from normal drupal session cookies. The trick is we must do this after // conf_init() (where drupal sets the session name, during // DRUPAL_BOOTSTRAP_CONFIGURATION), but before session_start() (during // DRUPAL_BOOTSTRAP_SESSION). The only way to do this is to define our own // session.inc. // Ensure unique session for facebook app. if (!isset($conf['session_inc'])) { $conf['session_inc'] = dirname(__FILE__) . '/fb_session.inc'; }