title: Setting multiple cookie in javascript
body: <p>I'm trying to set multiple cookies in document.cookie, but unfortunately my code shows the cookie value as null and undefined. My code is as belows:</p>
  
  <pre><code>&lt;script&gt;
  function set_cookie ( name, value, exp_y, exp_m, exp_d, path, domain, secure )
  {
    var cookie_string = name + "=" + escape ( value );
  
    if ( exp_y )
    {
      var expires = new Date ( exp_y, exp_m, exp_d );
      cookie_string += "; expires=" + expires.toGMTString();
    }
  
    if ( path )
          cookie_string += "; path=" + escape ( path );
  
    if ( domain )
          cookie_string += "; domain=" + escape ( domain );
  
    if ( secure )
          cookie_string += "; secure";
  
    document.cookie = cookie_string;
  }
  &lt;/script&gt;
  &lt;script&gt;
  
  alert(setCookie( "username", "Miron" ));
  alert(setCookie( "username", "Mirion", 2003, 01, 15 ));
  alert(setCookie("username", "John Smith", 2003, 01, 15, "","elated.com", "secure"))
  &lt;/script&gt;
  </code></pre>
  
  <p>I technically see no fault in the code. Please tell me where I had gone wrong</p>