refactoring and allowing for cookie re-auth