title: JavaScript set cookies
body: <p>I'm a bit stuck on some javascript. So the script below sets eith one of two cookies.</p>
  
  <p>If the page contains 'lpt' and a cookie called organic doesn't exist (not sure if the second part actually works) then create a cookie. Otherwise create a different one.</p>
  
  <p>Problem is which ever cookie is created needs to be held and not swap them out? ie if the first one is created don't ever create the other one.</p>
  
  <pre><code>if(document.URL.indexOf("lpt") &gt;= 0 &amp;&amp; document.cookie.indexOf("organic") &lt; 0){ 
      document.cookie = "ppc_campaign=this will be the url; expires=Thu, 18 Dec 2018 12:00:00 UTC; path=/";
      }
      else {
      document.cookie = "organic=this will be the url; expires=Thu, 18 Dec 2013 12:00:00 UTC; path=/";
      }
  </code></pre>