Refactored code, helper method to check for cookie doginess on each API call and if so to sign the user out