create CookieManager "class"

...and update the callers to its methods. think OOP !