title: store array of objects in cookie, pure javascript, no jquery?
body: <p>I am trying to store array of object inside cookie.</p>
  
  <p>Without using jQuery or angular.</p>
  
  <pre><code>function setCook (name,value) {
    var cookie = [name, '=', JSON.stringify(value)].join('');
    document.cookie = cookie;
  }
  
  function readCookie(name) {
    var nameEQ = name + "=";
    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,c.length);
      if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
  }
  </code></pre>