Second draft of the session cookie support
Tidying up
merging latest