cookie.c: Refactored cleanup code to simplify

Also, fixed the outdated comments on the cookie API.