diff --git a/securelogin.module b/securelogin.module
index 3e74266..7aea416 100644
--- a/securelogin.module
+++ b/securelogin.module
@@ -120,3 +120,43 @@
     $options['absolute'] = TRUE;
   }
 }
+
+/**
+ * Implementation of hook_boot().
+ */
+function securelogin_boot() {
+  global $base_root, $base_url, $is_https;
+  // If user has a session on ssl site issue a redirect
+  // @todo Should we care if user is logged in or has a session on
+  //       insecure site?
+  if (!$is_https && isset($_COOKIE['SECUREAUTH'])) {
+    drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
+    // Redirect to HTTPS version of this page.
+    $path = request_path();
+    $query = NULL;
+    if (count($_GET) > 1) {
+      // Remove q since it's in $path.
+      unset($_GET['q']);
+      $query = $_GET;
+    }
+    $base = 'https://' . parse_url($base_url, PHP_URL_HOST) . base_path();
+    // @todo Allow other modules to restrict which paths get redirected.
+    // Issue redirect.
+    drupal_goto($base . $path, array('query' => $query));
+  }
+  elseif ($is_https) {
+    // Set the cookie if session is present
+    //drupal_set_message(print_r($_SESSION, TRUE));
+    if (!isset($_COOKIE['SECUREAUTH']) && isset($_SESSION)) {
+      $params = session_get_cookie_params();
+      $expire = $params['lifetime'] ? REQUEST_TIME + $params['lifetime'] : 0;
+      setcookie('SECUREAUTH', 1, $expire, $params['path'], $params['domain'], FALSE);
+    }
+    elseif (isset($_COOKIE['SECUREAUTH']) && !isset($_SESSION)) {
+      // Delete the cookie if isset but the session is not.
+      $params = session_get_cookie_params();
+      setcookie('SECUREAUTH', 'deleted', REQUEST_TIME - 3600, '/', $params['domain'], FALSE);
+      unset($_COOKIE['SECUREAUTH']);
+    }
+  }
+}
\ No newline at end of file