title: Fixing the class to enable object storing in Flask session
body: <p>I have a custom class Passport that contains the active user identity and permissions. I used to store it in session just like this:</p>
  
  <pre><code>p = Passport()
  p.do_something_fancy()
  session["passport"] = p
  </code></pre>
  
  <p>and it just worked. Now, after server upgrade, I am receiving this error:</p>
  
  <pre><code>TypeError: &lt;userman.Passport instance at 0x7f06e9356f38&gt; is not JSON serializable
  </code></pre>
  
  <p>I guess it is connected to some upgrades in Flask that now require the object to be JSON-serializable to be stored in session. But how do I properly make an object JSON-serializable? Perhaps I have to provide a method for serialization and also a method for deserialization, to restore the object state when it's being loaded again?</p>