Minor refactoring to centralize handling of the login cookie checks.