title: javascript set cookie with language value
body: <p>I need to set a cookie that saves the language value selected from a drop-down menu in page 1 and carry the cookie until page 4. So that in page 3 (where the language selection is longer there) a text appears depending on the language selected in page 1.</p>
  
  <p>The language selection in page 1 is:</p>
  
  <pre><code>&lt;select id="languages" onchange="submit();"&gt;
  &lt;option value="en" &gt;English&lt;/option&gt;
  &lt;option value="es" selected&gt;Spanish&lt;/option&gt;
  &lt;option value="fr"&gt;French&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>The cookie should be set immediately as soon as the page opens the first time and the value should get updated if the user changes the language in the drop-down menu from page 1. The cookie should be kept until page 4.</p>
  
  <p>Any ideas how to set the cookie and then read it so the text in page page 3 appears in the language chosen in page 1?</p>
  
  <p>The text that needs to appear in the selected language is not part of the HTML and it's being inserted via Javascript as follows:</p>
  
  <pre><code>$(document).ready(function () {
  if ($('page_3').length) {
  $('#my_element').after('&lt;div id="greet"&gt;&lt;/div&gt;XXXXXX&lt;/div&gt;');
  }
  });
  </code></pre>
  
  <p>The code should first check the language value from the cookie and replace the 'XXXXXX' with the respective text depending on the language cookie value:</p>
  
  <pre><code>var welcome = {
  en:"English",
  es:"Espanol",
  fr:"Francais"
  }
  $(document).ready(function () {
  $('#greet').html(welcome[$('#languages').val()]);
  });
  </code></pre>
  
  <p>Any ideas?</p>