The "headers already sent" error means that the HTTP headers have already been sent to the browser, and then somewhere in your script you attempted to send more HTTP headers. In this case, it looks like the first header warning is because you are trying to send another Cookie header when it has already been sent... headers are sent with the header() function so you may want to search for that.
Also, you can use the output buffering functions to keep from sending content to the browser until you tell it. Just call ob_start() at the beginning of your script and ob_end_flush() at the end... there are other output buffering functions you can also take a look at...