diff --git a/includes/locale_cookie.inc b/includes/locale_cookie.inc
index 48526ee..6300d16 100644
--- a/includes/locale_cookie.inc
+++ b/includes/locale_cookie.inc
@@ -1,25 +1,41 @@
-<?php
-
-/**
- * @file
- * Administration functions for locale_cookie.module.
- */
-
-/**
- * Identify language from a request/cookie parameter.
- *
- * @param $languages
- *   An array of valid language objects.
- *
- * @return
- *   A valid language code on success, nothing otherwise.
- */
-function locale_cookie_language_from_cookie($languages) {
-  global $base_path;
-  $param = variable_get('locale_cookie_language_negotiation_cookie_param', 'language');
-
-  if (isset($_COOKIE[$param]) && isset($languages[$langcode = $_COOKIE[$param]])) {
-    $langcode = $_COOKIE[$param];
-    return $langcode;
-  }
-}
\ No newline at end of file
+<?php
+
+/**
+ * @file
+ * Administration functions for locale_cookie.module.
+ */
+
+/**
+ * Identify language from a request/cookie parameter.
+ *
+ * @param $languages
+ *   An array of valid language objects.
+ *
+ * @return
+ *   A valid language code on success, FALSE otherwise.
+ */
+function locale_cookie_language_from_cookie($languages) {
+  global $base_path;
+  $param = variable_get('locale_cookie_language_negotiation_cookie_param', 'language');
+
+  if (isset($_COOKIE[$param]) && isset($languages[$langcode = $_COOKIE[$param]])) {
+    $langcode = $_COOKIE[$param];
+  }
+  else {
+    global $language;
+    if (is_object($language)) {
+      $langcode = $language->language;
+    }
+    else {
+      $langcode = language_default('language');
+    }
+  }
+  $expire = REQUEST_TIME + (86400 * variable_get('locale_cookie_language_negotiation_cookie_expire', 7));
+  $path = variable_get('locale_cookie_language_negotiation_cookie_path', $base_path);
+  $domain = variable_get('locale_cookie_language_negotiation_cookie_domain', '');
+  $secure = variable_get('locale_cookie_language_negotiation_cookie_secure', 0);
+  $http_only = variable_get('locale_cookie_language_negotiation_cookie_http_only', 0);
+  
+  setcookie($param, $langcode, $expire, $path, $domain, $secure, $http_only);
+  return $langcode;
+}
diff --git a/locale_cookie.admin.inc b/locale_cookie.admin.inc
index b80f1b6..2689479 100644
--- a/locale_cookie.admin.inc
+++ b/locale_cookie.admin.inc
@@ -1,24 +1,61 @@
-<?php
-
-/**
- * The cookie language provider configuration form.
- */
-function locale_cookie_language_providers_cookie_form($form, &$form_state) {
-  $form['locale_cookie_language_negotiation_cookie_param'] = array(
-    '#title' => t('Request/cookie parameter'),
-    '#type' => 'textfield',
-    '#default_value' => variable_get('locale_cookie_language_negotiation_cookie_param', 'language'),
-    '#description' => t('Name of the request/cookie parameter used to determine the desired language.'),
-  );
-
-  $form['locale_cookie_language_negotiation_cookie_expire'] = array(
-    '#title' => t('Expire'),
-    '#type' => 'textfield',
-    '#default_value' => variable_get('locale_cookie_language_negotiation_cookie_expire', 7),
-    '#description' => t('The time (in days) in which the cookie should expire.'),
-  );
-
-  $form_state['redirect'] = 'admin/config/regional/language/configure';
-
-  return system_settings_form($form);
-}
\ No newline at end of file
+<?php
+
+/**
+ * The URL language provider configuration form.
+ */
+function locale_cookie_language_providers_cookie_form($form, &$form_state) {
+  global $base_path;
+  
+  $form['locale_cookie_language_negotiation_cookie_param'] = array(
+    '#title' => t('Cookie name'),
+    '#type' => 'textfield',
+    '#default_value' => variable_get('locale_cookie_language_negotiation_cookie_param', 'language'),
+    '#description' => t('Name of the request/cookie parameter used to determine the desired language.'),
+  );
+
+  $form['locale_cookie_language_negotiation_cookie_expire'] = array(
+    '#title' => t('Cookie expire'),
+    '#type' => 'textfield',
+    '#default_value' => variable_get('locale_cookie_language_negotiation_cookie_expire', 7),
+    '#description' => t('The time (in days) in which the cookie should expire.'),
+  );
+
+  $form['locale_cookie_language_negotiation_cookie_path'] = array(
+    '#title' => t('Cookie path'),
+    '#type' => 'textfield',
+    '#default_value' => variable_get('locale_cookie_language_negotiation_cookie_path', $base_path),
+    '#description' => t('The path on the server in which the cookie will be available on.'),
+  );
+
+  $form['locale_cookie_language_negotiation_cookie_domain'] = array(
+    '#title' => t('Cookie domain scope'),
+    '#type' => 'textfield',
+    '#default_value' => variable_get('locale_cookie_language_negotiation_cookie_domain', ''),
+    '#description' => t('The domain that the cookie is available to.'),
+  );
+  
+  $form['locale_cookie_language_negotiation_cookie_secure'] = array(
+    '#title' => t('Cookie secure'),
+    '#type' => 'radios',
+    '#default_value' => variable_get('locale_cookie_language_negotiation_cookie_secure', 0),
+    '#options' => array(
+      0 => t('Disabled'),
+      1 => t('Enabled')
+    ),
+    '#description' => t('When this option is set to "Enabled" the cookie should be only transmitted over a secure HTTPS connection from the client. The cookie will only be set if a secure connection exists.'),
+  );
+  
+  $form['locale_cookie_language_negotiation_cookie_http_only'] = array(
+    '#title' => t('Cookie HTTP only'),
+    '#type' => 'radios',
+    '#default_value' => variable_get('locale_cookie_language_negotiation_cookie_http_only', 0),
+    '#options' => array(
+      0 => t('Disabled'),
+      1 => t('Enabled')
+    ),
+    '#description' => t('When this option is set to "Enabled" the cookie will be made accessible only through the HTTP protocol. This means that the cookie won\'t be accessible by scripting languages, such as JavaScript. It has been suggested that this setting can effectively help to reduce identity theft through XSS attacks.'),
+  );
+  
+  $form_state['redirect'] = 'admin/config/regional/language/configure';
+  return system_settings_form($form);
+}
diff --git a/locale_cookie.info b/locale_cookie.info
index 86fd313..f980499 100644
--- a/locale_cookie.info
+++ b/locale_cookie.info
@@ -4,3 +4,13 @@ package = Locale
 version = VERSION
 core = 7.x
 configure = admin/config/regional/language
+
+files[] = locale_cookie.module
+files[] = locale_cookie.admin.inc
+files[] = includes/locale_cookie.inc
+; Information added by drupal.org packaging script on 2011-08-11
+version = "7.x-1.0"
+core = "7.x"
+project = "locale_cookie"
+datestamp = "1313073120"
+
diff --git a/locale_cookie.module b/locale_cookie.module
index 1492a58..f8cbd8b 100644
--- a/locale_cookie.module
+++ b/locale_cookie.module
@@ -1,63 +1,93 @@
-<?php
-
-// $Id$
-/**
- * @file
- *
- */
-define('LOCALE_COOKIE_NEGOTIATION_COOKIE', 'language-cookie');
-
-/**
- * Implements hook_init().
- */
-function locale_cookie_init() {
-  global $base_path, $language, $cookie_domain;
-  $param = variable_get('locale_cookie_language_negotiation_cookie_param', 'language');
-  if (isset($_COOKIE[$param])) {
-    if (is_object($language) && $_COOKIE[$param] != $language->language) {
-      $langcode = $language->language;
-    }
-    else {
-      $langcode = $_COOKIE[$param];
-    }
-  }
-  else {
-    $langcode = $language->language;
-  }
-  $expire = REQUEST_TIME + (86400 * variable_get('locale_cookie_language_negotiation_cookie_expire', 7));
-  setcookie($param, $langcode, $expire, $base_path, $cookie_domain);
-}
-
-/**
- * Implements hook_language_negotiation_info().
- */
-function locale_cookie_language_negotiation_info() {
-  $file = drupal_get_path('module', 'locale_cookie') . '/includes/locale_cookie.inc';
-  $providers[LOCALE_COOKIE_NEGOTIATION_COOKIE] = array(
-    'types' => array(LANGUAGE_TYPE_CONTENT, LANGUAGE_TYPE_INTERFACE, LANGUAGE_TYPE_URL),
-    'callbacks' => array(
-      'language' => 'locale_cookie_language_from_cookie',
-    ),
-    'file' => $file,
-    'weight' => -8,
-    'name' => t('Cookie'),
-    'description' => t('Determine the language from a cookie.'),
-    'config' => 'admin/config/regional/language/configure/cookie',
-  );
-  return $providers;
-}
-
-/**
- * Implements hook_menu().
- */
-function locale_cookie_menu() {
-  $items['admin/config/regional/language/configure/cookie'] = array(
-    'title' => 'Cookie language detection configuration',
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('locale_cookie_language_providers_cookie_form'),
-    'access arguments' => array('administer languages'),
-    'file' => 'locale_cookie.admin.inc',
-    'type' => MENU_VISIBLE_IN_BREADCRUMB,
-  );
-  return $items;
+<?php
+
+// $Id$
+/**
+ * @file
+ *
+ */
+define('LOCALE_COOKIE_NEGOTIATION_COOKIE', 'language-cookie');
+
+function locale_cookie_init() {
+  global $base_path;
+  global $language;
+  $param = variable_get('locale_cookie_language_negotiation_cookie_param', 'language');
+  if (isset($_COOKIE[$param])) {
+    if (is_object($language) && $_COOKIE[$param] != $language->language) {
+      $langcode = $language->language;
+    }
+    else {
+      $langcode = $_COOKIE[$param];
+    }
+  }
+  else {
+    $langcode = $language->language;
+  }
+  $expire = REQUEST_TIME + (86400 * variable_get('locale_cookie_language_negotiation_cookie_expire', 7));
+  $path = variable_get('locale_cookie_language_negotiation_cookie_path', $base_path);
+  $domain = variable_get('locale_cookie_language_negotiation_cookie_domain', '');
+  $secure = variable_get('locale_cookie_language_negotiation_cookie_secure', 0);
+  $http_only = variable_get('locale_cookie_language_negotiation_cookie_http_only', 0);
+  
+  setcookie($param, $langcode, $expire, $path, $domain, $secure, $http_only);
+}
+
+function locale_cookie_language_negotiation_info() {
+  $file = drupal_get_path('module', 'locale_cookie') . '/includes/locale_cookie.inc';
+  $providers[LOCALE_COOKIE_NEGOTIATION_COOKIE] = array(
+    'types' => array(LANGUAGE_TYPE_CONTENT, LANGUAGE_TYPE_INTERFACE, LANGUAGE_TYPE_URL),
+    'callbacks' => array(
+      'language' => 'locale_cookie_language_from_cookie',
+    ),
+    'file' => $file,
+    'weight' => -8,
+    'name' => t('Cookie'),
+    'description' => t('Determine the language from a cookie.'),
+    'config' => 'admin/config/regional/language/configure/cookie',
+  );
+  return $providers;
+}
+
+function locale_cookie_menu() {
+  $items['admin/config/regional/language/configure/cookie'] = array(
+    'title' => 'Cookie language detection configuration',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('locale_cookie_language_providers_cookie_form'),
+    'access arguments' => array('administer languages'),
+    'file' => 'locale_cookie.admin.inc',
+    'type' => MENU_VISIBLE_IN_BREADCRUMB,
+  );
+  return $items;
+}
+
+/**
+ * Implement hook_url_outbound_alter().
+ */
+function locale_cookie_url_outbound_alter(&$path, &$options, $original_path) {
+  global $base_path;
+  global $language;
+
+  // Use only if it's the front page.
+  if (drupal_is_front_page() && request_uri() == $base_path) {
+    // Looking for the language value included in cookie language.
+    $param = variable_get('locale_cookie_language_negotiation_cookie_param', 'language');
+    if (isset($_COOKIE[$param])) {
+      if (is_object($language) && $_COOKIE[$param] != $language->language) {
+        $langcode = $language->language;
+      }
+      else {
+        $langcode = $_COOKIE[$param];
+      }
+    }
+    else {
+      $langcode = $language->language;
+    }
+
+    // Load the language object related to the language value found in cookie.
+    $languages = language_list();
+    $language = $languages[$langcode];
+
+    // Rewrite options to change the language.
+    $options['prefix'] = (!empty($language->prefix)) ? $language->prefix . $base_path : '';
+    $options['language'] = $language;
+  }
 }
\ No newline at end of file
