title: how to store javascript variables with cookies js
body: <p>I'm trying to make a simple program that stores the <code>h1</code> value in a variable and then store it in a cookie. But whenever I reload the page the <code>h1</code> value always goes back to 0 and is not being saved. Can someone please explain how I can save the variable in a cookie so when I reload the page it stays there.</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  
  &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;title&gt;&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;div class="container"&gt;
          &lt;h1 id="hs"&gt;1 &lt;/h1&gt; &lt;img src="image01.jpg" width="960" height="640" /&gt;
          &lt;button onclick="increase()" id="d"&gt;Increase value of cookie&lt;/button&gt;
      &lt;/div&gt;
      &lt;script src="cookies.min.js"&gt;&lt;/script&gt;
      &lt;script&gt;
          Cookies.set('name', 'leo');
          Cookies.set('nams', 'ddleo');
          var h = document.getElementById("hs");
  
          function increase() {
              var values = parseInt(document.getElementById('hs').innerHTML, 10);
              values++;
              Cookies.set("name", values);
              document.getElementById('hs').innerHTML = Cookies.get("name", values);
          }
      &lt;/script&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>