You put the setcookie() function before ANY output. Even a space, or a single return. If you have anything before the actual setcookie() function in your php execution, it will throw a warning about the header already being sent out (if your php.ini has warnings on).
Your second question, if you try to set a cookie with a variable, and the variable is empty, it will simply set an empty cookie. It will not error on you. Just make sure you put SOMETHING in the cookie value param (second param), or when users return to the site with the malformed cookie, the site will possibly hang on them (at least in the new 4.1x PHP it does this).
If you wish to set an empty cookie, use:
setcookie('cookiename','');
NEVER do this:
setcookie('cookiename');
I'm not sure why, but doing the second creates a cookie with contents of "0%2" or some combination of, and when you try to hit the website again with that cookie existing, it hangs.
This has never happened on my linux/php4.0.6 server, but it has occurred in servers I have used with the new 4.1x.