refactor cookieManager