title: How to make my website remember which CTA has been pressed to redirect
body: <p>I'm trying to make an page which is in both Spanish and English, so what I want to do is create a main page where the user must choose the language and once he does, I want the page to remember which language was chosen so instead of opening the main page again, it opens the language previously chosen.</p>
  
  <p>What would be the best approach?</p>
  
  <p>EDIT-- I tried the suggestion of localStorage, I am stuck, never used JavaScript so I should have seen this coming. I can write in 'locale' 'es' or 'en' but I can't redirect at all.
  This is the code:</p>
  
  <pre><code>&lt;script&gt;
      (function (){
    'use strict';
  
    var eng = document.querySelector('.eng')
  
    function setLocalStorage(){
       eng.addEventListener('click', () =&gt; {
        localStorage.setItem('locale','en')
      })
    }
    setLocalStorage()
  
  }());
          (function (){
    'use strict';
  
    var esp = document.querySelector('.esp')
  
    function setLocalStorage(){
       esp.addEventListener('click', () =&gt; {
        localStorage.setItem('locale','es')
      })
    }
    setLocalStorage()
  
  }());
          if (localStorage.getItem('en') === 'en') { window.location='eng.html'; }
          if (localStorage.getItem('es') === 'es') { window.location='esp.html'; }
      &lt;/script&gt;
  </code></pre>