Store sessions in db - DO NOT MERGE YET

Still work in progress branch, at the moment clients are told they have reconnected but after a few changesets the server stops accepting their changes (or the client stops sending them).