refactor cookies