Fixed issue where the cookie may not be set in some instances