Trying to set a cookie based on $_POST parameter

I’ve been able to set cookies properly at both the template_redirect and init action hooks. You might try using one of those instead.