Update the cookie class, improve API and functionality