title: How to update and delete a cookie?
body: <p>I need help to know how to update values and how to delete a <strong>cookie</strong> created from this code! I'm new to JavaScript so it's great if anyone can help me.</p>
  
  <pre><code>function getCookie(c_name) {
       var i,x,y,ARRcookies = document.cookie.split(";");
       for (i=0;i&lt;ARRcookies.length;i++) {
            x = ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
            y = ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
            x = x.replace(/^\s+|\s+$/g,"");
            if (x==c_name) {
                return unescape(y);
            }
        }
  }
  
  function setCookie(c_name,value,exdays) {
      var exdate = new Date();
      exdate.setDate(exdate.getDate() + exdays);
      var c_value = escape(value) + ((exdays==null) ? "" : ";                                    expires="+exdate.toUTCString());
     document.cookie=c_name + "=" + c_value;
   }
  
  function check2Cookie() {
       var username=getCookie("username");
       if (username!=null &amp;&amp; username!="") {
           username= "0";
           setCookie("username",username,1000);
       }
       else {
           username=" ";
           if (username!=null &amp;&amp; username!="") {
                 username= "0";
                 setCookie("username",username,1000);
           }
       }
  }
  </code></pre>
  
  <p>This is the code for cookie creation.</p>
  
  <p>Code for creating is <code>setCookie("username",username,1000);</code></p>
  
  <p>Now how to update this cookie and delete this cookie.</p>