title: Setting popup to open every 30 days
body: <p>I'm trying to set a cookie which every 30 days (or any other set time period) will launch for example Stackoverflow.com.</p>
  
  <p>I found an <a href="https://stackoverflow.com/questions/12926119/cookie-to-show-a-popup-every-30-days">answer here</a> which i thought might help.
  and here is my test code so far:
  The HTML + Initiator</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;!-- Load JQuery 1.8.3 and the repeatablePopup functions--&gt;
          &lt;script src="js/jquery-1.8.3.min.js"&gt;&lt;/script&gt;
          &lt;script src="js/repeatablePopup.js"&gt;&lt;/script&gt;
  
          &lt;script&gt;
              jQuery(document).ready(function() {
                  var visited = readCookie('visited');
                  if (!visited || visited !== "true") {
                      createCookie('visited', "true", 7);
                  } else {
                          window.open("http://stackoverflow.com");
                  }
              });
          &lt;/script&gt;
      &lt;/head&gt;
  
      &lt;body&gt;
          &lt;p&gt;Setting Cookie&lt;/p&gt;
      &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>The Funcitons on repeatablePopup.js</p>
  
  <pre><code>function createCookie(name,value,days) {
      if (days) {
          var date = new Date();
          date.setTime(date.getTime()+(days*24*60*60*1000));
          var expires = "; expires="+date.toGMTString();
      }
      else var expires = "";
      document.cookie = name+"="+value+expires+"; path=/";
      document.write('Cookie is set');
  }
  
  function readCookie(name) {
      var nameEQ = name + "=";
      var ca = document.cookie.split(';');
      for(var i=0;i &lt; ca.length;i++) {
          var c = ca[i];
          while (c.charAt(0)==' ') c = c.substring(1,c.length);
          if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
      }
      return null;
  }
  
  function eraseCookie(name) {
      createCookie(name,"",-1);
  }
  </code></pre>
  
  <p>Edit: problem now is that cookie is planted every time I refresh the page, even though the cookie exists.
  So eventually the pop up isn't working.</p>
  
  <p>Thanks for any help given,
  Shahar</p>