cookies are header information and have to be the first thing sent to the browser..
other header iformation like header(location🙂 information can mess things up too.
try setting the cookie as the first thing on the page.
also, while troubleshooting cookies.. remember to keep deleting all your cookies or it is impossible to debug.
if it's still a problem, post the code above where you are setting the cookie.