Setup user session and login function.