(feat) Cookie.

Can this helper function be moved out into another place in the code? That way you can use it in both places and this will be much more readable.