diff --git a/session_api.admin.inc b/session_api.admin.inc
index d6bb27b..c918e32 100644
--- a/session_api.admin.inc
+++ b/session_api.admin.inc
@@ -17,7 +17,7 @@ function session_api_settings_form() {
   $form['session_api_cookie_expire_time'] = array(
     '#type' => 'textfield',
     '#title' => t('Cookie expire time'),
-    '#description' => t("The <strong>Session API</strong> module sets an additional cookie in the end users' browsers in order to better track sessions across logins and logouts. This is the amount of time, in seconds, that the cookie will stay valid in a user's browser."),
+    '#description' => t("The <strong>Session API</strong> module sets an additional cookie in the end users' browsers in order to better track sessions across logins and logouts. This is the amount of time, in seconds, that the cookie will stay valid in a user's browser. If set to -1, then the cookie will expire when the session ends (i.e, when the browser closes)"),
     '#default_value' => variable_get('session_api_cookie_expire_time', 2592000),
   );
 
diff --git a/session_api.module b/session_api.module
index 985b592..083c734 100644
--- a/session_api.module
+++ b/session_api.module
@@ -64,13 +64,20 @@ function session_api_get_sid($create = TRUE) {
 
     // For the cookie we use the same domain that Drupal's own session cookie uses.
     $cookie_domain = ini_get('session.cookie_domain');
+
+    // Set expiration time. If -1, then use an expiration time of 0, which will
+    // cause the cookie to expire when the session ends (i.e, when the browser
+    // closes).
+    $seconds = variable_get('session_api_cookie_expire_time', 2592000);
+    $expire = $seconds === -1 ? time() + $seconds : 0;
+
     // Update the session timeout.
     if ($sid) {
       $rec = new stdClass;
       $rec->sid = $sid;
       $rec->session_id = $session_id;
       drupal_write_record('session_api', $rec, 'sid');
-      setcookie('session_api_session', $session_id, time() + variable_get('session_api_cookie_expire_time', 2592000), '/', $cookie_domain);
+      setcookie('session_api_session', $session_id, $expire, '/', $cookie_domain);
     }
     // No sid exists, create new one.
     else {
@@ -80,7 +87,7 @@ function session_api_get_sid($create = TRUE) {
       $sid = $rec->sid;
 
       // Set cookie.
-      setcookie('session_api_session', $session_id, time() + variable_get('session_api_cookie_expire_time', 2592000), '/', $cookie_domain);
+      setcookie('session_api_session', $session_id, $expire, '/', $cookie_domain);
     }
   }
   return $sid;
