title: Multilingual PHP Site with browser's lnaguage detection and Cookie
body: <p>I would like to make my site multilingual. How can I simply include the right language file by FIRST detecting the browser's language and THEN by setting a cookie if the user clicks on a language flag present on each page.</p>
  
  <p>I found this script:</p>
  
  <pre><code>&lt;script&gt;
  
  /*
  Browser Language Redirect script- By JavaScript Kit
  For this and over 400+ free scripts, visit http://www.javascriptkit.com
  This notice must stay intact
  */
  
  //Enter ISO 639-2 letter Language codes to detect (see: http://www.w3.org/WAI/ER/IG/ert/iso639.htm):
  var langcodes=new Array("en", "de", "it", "default")
  
  //Enter corresponding redirect URLs (last one is for default URL):
  var langredirects=new Array("english/index.php", "deutsch/index.php", "italiano/index.php", "english/index.php")
  
  var languageinfo=navigator.language? navigator.language : navigator.userLanguage
  var gotodefault=1
  
  function redirectpage(dest){
  if (window.location.replace)
  window.location.replace(dest)
  else
  window.location=dest
  }
  
  for (i=0;i&lt;langcodes.length-1;i++){
  if (languageinfo.substr(0,2)==langcodes[i]){
  redirectpage(langredirects[i])
  gotodefault=0
  break
  }
  }
  
  if (gotodefault)
  redirectpage(langredirects[langcodes.length-1])
  
  
  &lt;/script&gt;
  </code></pre>