title: Save Javascript objects in sessionStorage
body: <p>SessionStorage and LocalStorage allows to save key/value pairs in a web browser. The value must be a string, and save js objects is not trivial.</p>
  
  <pre><code>var user = {'name':'John'};
  sessionStorage.setItem('user', user);
  var obj = sessionStorage.user; // obj='[object Object]' Not an object
  </code></pre>
  
  <p>Nowadays, you can avoid this limitation by serializing objects to JSON, and then deserializing them to recover the objects. But the Storage API always pass through the <code>setItem</code> and <code>getItem</code> methods.</p>
  
  <pre><code>sessionStorage.setItem('user', JSON.stringify(user));
  var obj = JSON.parse(sessionStorage.getItem('user')); // An object :D
  </code></pre>
  
  <p>Can I avoid this limitation?</p>
  
  <p>I just want to execute something like this:</p>
  
  <pre><code>sessionStorage.user.name; // 'John'
  sessionStorage.user.name = 'Mary';
  sessionStorage.user.name // 'Mary'
  </code></pre>
  
  <p>I have tried the <code>defineGetter</code> and <code>defineSetter</code> methods to intercept the calls but its a tedious job, because I have to define all properties and my target is not to know the future properties.</p>