Fix cookie memory leaks