Safe and modular cookie handler