Move cookie generation into its own library