title: How to read cookie value with javascript?
body: <pre><code>&lt;script type="text/javascript"&gt;
  function WorldwideSellingModelCookie(){
     days=7;
     myDate = new Date();
     myDate.setTime(myDate.getTime()+(days*24*60*60*1000));
     document.cookie = 'WorldwideSellingModelCookie=Accepted; expires=' + myDate.toGMTString();
  }
  function CheckCookies(){  
      var worldwideSellingCookie = getCookie("WorldwideSellingModelCookie"); 
      if (worldwideSellingCookie == "Accepted")
      {
          jQuery(".alert-worldwide").hide();
      } 
  }
  CheckCookies();
  &lt;/script&gt;
  </code></pre>
  
  <p>Hi,</p>
  
  <p>The cookie is being created, I am just unsure how to get my if statement to work within my CheckCookies function so that it hide a div on the page?</p>
  
  <p>I am recieving the following console error:</p>
  
  <blockquote>
    <p>Uncaught ReferenceError: getCookie is not defined</p>
  </blockquote>
  
  <p>Can anyone advise what I am doing wrong?</p>
  
  <p>Thanks</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  function WorldwideSellingModelCookie(){
     days=7;
     myDate = new Date();
     myDate.setTime(myDate.getTime()+(days*24*60*60*1000));
     document.cookie = 'WorldwideSellingModelCookie=Accepted; expires=' + myDate.toGMTString();
  }
  
  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 CheckCookies(){  
      var worldwideSellingCookie = getCookie("WorldwideSellingModelCookie"); 
      if (worldwideSellingCookie == "Accepted")
      {
          jQuery(".alert-worldwide").hide();
      } 
  }
  CheckCookies();
  &lt;/script&gt;
  </code></pre>
  
  <p>Just added the function to check the cookie and seems to be working now, however the div appears for a split second before hiding. Is there any way to stop this from happening?</p>