separate out cookie parsing

Change-Id: Ia41824be01004bb2b79f35b88f0c70c51f4b644d