--- fboauth.module	Mon Jan 19 23:26:36 1970
+++ fboauth.module	Mon Jan 19 23:26:36 1970
@@ -435,3 +435,15 @@
   }
   return $output;
 }
+
+/**
+ * Implements hook_user_logout()
+ **/ 
+function fboauth_user_logout() {
+    global $base_url;
+    if (variable_get("fboauth_fb_logout",0)) {
+      $url = "https://www.facebook.com/logout.php?next=$base_url&access_token=" . $_SESSION['fboauth_access_token'];
+      session_destroy();
+      drupal_goto($url);
+    }
+}
--- fboauth.fboauth.inc	Mon Jan 19 23:26:36 1970
+++ fboauth.fboauth.inc	Mon Jan 19 23:26:36 1970
@@ -117,6 +117,8 @@
       drupal_set_message('Your Facebook e-mail address does not match any existing accounts. If you have an account, you must first log in before you can connect your account to Facebook. Creation of new accounts on this site is disabled.');
     }
   }
+    $_SESSION['fboauth_access_token'] = $access_token;
+  
 }
 
 /**
@@ -228,6 +230,7 @@
 
   // Allow other modules to manipulate the user information after save.
   foreach (module_implements('fboauth_user_save') as $module) {
+   
     $function = $module . '_fboauth_user_save';
     $function($account, $fbuser);
   }
--- fboauth.pages.inc	Mon Jan 19 23:26:36 1970
+++ fboauth.pages.inc	Mon Jan 19 23:26:36 1970
@@ -28,6 +28,14 @@
     '#default_value' => variable_get('fboauth_secret', ''),
   );
 
+  $form['fboauth_fb_logout'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Auto-logout from Facebook'),
+    '#description' => t('Logout from site will logout from Facebook.'),
+    '#options' => array(0 => t("No"), 1 => t("Yes")),
+    '#default_value' => variable_get('fboauth_fb_logout', 0),
+  );
+
   $form['fboauth_basic_mapping'] = array(
     '#type' => 'fieldset',
     '#title' => t('Basic mapping'),
@@ -141,6 +149,7 @@
 function fboauth_settings_form_submit($form, &$form_state) {
   variable_set('fboauth_id', $form_state['values']['fboauth_id']);
   variable_set('fboauth_secret', $form_state['values']['fboauth_secret']);
+  variable_set('fboauth_fb_logout', $form_state['values']['fboauth_fb_logout']);
 
   variable_set('fboauth_user_email', $form_state['values']['fboauth_user_email']);
   variable_set('fboauth_user_username', $form_state['values']['fboauth_user_username']);
