Working sessions. State can now be saved and restored.

We need to expire these sessions but for now it should be ok.