title: Pure Javascript - store object in cookie
body: <p>No jQuery. </p>
  
  <p>I want to store an object or array in a cookie.</p>
  
  <p>The object should be usable after page refresh.</p>
  
  <p>How do I do that with pure JavaScript? I read many posts, but do not know how to serialize appropriately.</p>
  
  <hr>
  
  <p>EDIT:
  Code:</p>
  
  <pre><code>var instances = {};
  ...
  instances[strInstanceId] = { container: oContainer };
  ...
  instances[strInstanceId].plugin = oPlugin;
  ...
  JSON.stringify(instances); 
  // throws error 'TypeError: Converting circular structure to JSON'
  </code></pre>
  
  <ol>
  <li><p>How do I serialize <code>instances</code>?</p></li>
  <li><p>How do I maintain functionality, but change structure of instance to be able to serialize with <code>stringify</code>?</p></li>
  </ol>