cookie construction gets its own function