title: Detect re-visitors using LocalStorage
body: <p>I know we can detect a re-visitor using cookies. But, is there a way to detect using LocalStorage only?</p>
  
  <p>This is what I have started with. I have a LocalStorage object called "ifVisited", whose value will change to "true" only when the user is visiting the 2nd time.</p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
  &lt;!–– Some code ––&gt;
  &lt;/body&gt;
  
  &lt;script&gt;
  localStorage.setItem('ifVisited', 'false');
  var cat = localStorage.getItem("ifVisited");
  
  
  &lt;!-- **How do I detect if the user is re-visiting?** --&gt;
  
  if(visit == 1) 
  {message=" Visit #1!";
  var cat = localStorage.getItem("ifVisited");
  &lt;!-----------------Do Nothing------------------&gt;
  }
  if(visit == 2) 
  {
  localStorage.setItem('ifVisited', 'true');
  var cat = localStorage.getItem("ifVisited");
  
  message=" 2nd Visit, Push Promo"
  &lt;!-----------------Push Promo------------------&gt;
  
  }
  if(visit &gt; 2) 
  {
  message=" Visit #3!";
  var cat = localStorage.getItem("ifVisited");
  age.setItem('ifVisited', 'false');
  &lt;!-----------------Do Nothing------------------&gt;
  }
  &lt;/script&gt;
  &lt;/html&gt;
  </code></pre>