title: How to correctly GET javascript Cookie?
body: <p>On this <a href="http://triathlon.joomlatest01.mms-dev.com/" rel="nofollow">test site</a>, I had a fancybox lightbox popping up fine. Then I added code in hopes to have it only popup on FIRST visit, but never again after.  So I have some JS below that runs setCookie() when either link in the lightbox is clicked.  And onload, I run checkCookie(). If the cookie exists, don't show the lightbox.  If it doesn't exist, show the lightbox.  </p>
  
  <p>With my new setting, getting and checking code, I can't get the lightbox to work now, and I'm pretty sure it's because getCookie isn't properly "getting" the cookie. Does anyone see anything obviously wrong?</p>
  
  <p>
      
      
      </p>
  
  <pre><code>function setCookie() {
  document.cookie="lightboxcookie=lightboxseen; expires=Thu, 18 Dec 2020 12:00:00 UTC";
  }
  
  function getCookie(cname) {
      var name = cname + "=";
      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);
          if (c.indexOf(name) == 0) {
              return c.substring(name.length, c.length);
          }
      }
      return "";
  }
  
  function checkCookie() {
   var thecookie=getCookie("lightboxcookie");
      if (thecookie != "") {
          } else {
              &lt;!--Show Lightbox--&gt;
              jQuery.noConflict()(function ($) { 
                  $(document).ready(function() { 
                      $(".lightbox").fancybox();
                      $(".lightbox").eq(0).trigger('click');
                      $(".lightbox").fancybox({
                          helpers : {
                              overlay : { 
                                  css : {
                                      opacity: 0.8,
                                      'background-color' : '#ff0000'
                                  }
                              }
                          }
                      });
                  });
              });
         }
      }
  }
  
  &lt;/script&gt;
  </code></pre>