fix memleak in cookie handling
prepared for listing/scanning directories