Whenever you get a "Cannot modify header information - headers already sent by" sort of error, it means that you have used header() or setcookie() after writing output.
Check your script for even things like "<html>" or an echo or print statement before the header(), or blank lines at the top.