Move cookie serialization out of form logic