title: How to only allow a popup message to occur on first visit with jQuery
body: <p>I'm working to include a GDPR-style / Cookie notification for when users visit our site for the first time, but not again until they clear their cache. I have a notification set up to show when the window opens, and a close button to close it.</p>
  
  <p>I've tried using localStorage and sessionStorage jquery, similar to those used to help other users, including hiding the popup first then checking in localStorage to see if it's there: </p>
  
  <pre><code> $(document).ready(function() {
          $('#toast').hide();
          var element= localStorage.getItem('status');
          if (element == null || element == '') {
              localStorage.setItem('element', 1);
              $('#toast').show();
          }});
  </code></pre>
  
  <p>But 1) I don't want to copy pasta because 2) it doesn't work. </p>
  
  <p>html for the popup here:</p>
  
  <pre><code>&lt;div id="toast" class="toast-close fixed-bottom" style="background-color: #DB7232; color: white; opacity: .7; margin: 0 0 2rem 2rem; padding: 1rem; width: 18rem;"&gt;
       &lt;small&gt;By continuing to browse this site, you're accepting the use of cookies.&lt;/small&gt;
       &lt;small&gt;&lt;button type="button" data-dismiss="toast" class="close" aria-label="Close"&gt;&amp;times&lt;/button&gt;&lt;/small&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>the jquery to close the popup here:</p>
  
  <pre><code>    $(document).on('click', '.toast-close', function() {
          $(this).fadeOut(function(){
             $(this).remove();
          });
      });
  </code></pre>
  
  <p>I expect when a user comes to our site for the first time (or since we add this feature) the popup will occur; once they x out of either the popup or the browser, the notification will not occur again until their cache is cleared.</p>