title: How to save a javascript variable
body: <p>I have a javascript variable, which is incremented by a javascript function in a .php script, only problem is that the page reloads when the function is called, so I need some way of saving the variable to be the same when the page is either reloaded or whenever you enter it. 
  I know you can do a local save but I am not quiet sure if it saves the variable when you leave the website.</p>
  
  <p>My variable is in a html script.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt; 
  
                      var varNumber= 1;
                      document.getElementById("varNumber").innerHTML = varNumber;
                      document.getElementByID("varNumber").value = varNumber;
  
  
                      function addToVariable() {
                          varNumber= varNumber+ 1 ;
                          document.getElementById("varNumber").innerHTML = varNumber;
                      }
  
                  &lt;/script&gt;
  </code></pre>