--- fboauth.module	Mon Jan 19 23:26:36 1970
+++ fboauth.module	Mon Jan 19 23:26:36 1970
@@ -434,3 +434,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,7 @@
       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;
 }
 
 /**
--- fboauth.pages.inc	Mon Jan 19 23:26:36 1970
+++ fboauth.pages.inc	Mon Jan 19 23:26:36 1970
@@ -27,6 +27,14 @@
     '#description' => t('To use Facebook connect, a Facebook Application must be created. Set up your app in <a href="http://www.facebook.com/developers/apps.php">my apps</a> on Facebook.') . ' ' . t('Enter your App Secret here.'),
     '#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',
@@ -137,6 +145,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']);
