title: JavaScript cookie, track visits
body: <p>I want to create a way to track how many times a user has visited a page.</p>
  
  <p>Problem is that i want to only increase the cookie visit count if more than 30 minutes have past since the last visit.</p>
  
  <p>How could i do this?</p>
  
  <p>Right now this is what i have to set and get cookie:</p>
  
  <pre><code>getCookie('xVisitors');
  setCookie('xVisitors', 1, 120);
  
  
  function setCookie(b, c, e) {
      var i = "";
      e &gt; 0 &amp;&amp; (i = new Date, i.setTime(i.getTime() + e * 6E4), i = "; expires=" + i.toGMTString());
      e = "";
      document.cookie = b + "=" + c + i + "; path=/;" + e
  };
  
  function getCookie(b) {
      for (var c = document.cookie.split(";"), e = 0; e &lt; c.length; e++) {
          for (var i = c[e]; i.charAt(0) == " ";) i = i.substring(1, i.length);
              if (i.indexOf(b) == 0) return i.substring(b.length + 1, i.length);
          }
      return "";
  } 
  </code></pre>