Implements most of sign in, with Sessions and Cookie support.