Added more code for custom auth.
added user auth.
Fixed session saving and restoring.