'Line 170' does not belong there, but if that was in your actual code you would be getting a parse error so I assume that slipped into the editting.
'Headers already sent' is a common error. The first time I encountered it I did a google search which wasn't much help because it found hundreds of sites who were actually displaying that error. A search on the topics of a site like this using the key expression "headers already sent" will yield more fruitful results, several of which answer your question.
You get that error by trying to print something out before you send the header information (a cookie, in this case) Since your cookie is in a function, you need to make sure you are not printing anything out before you call the function.
Another common thing that will generate that warning in some cases is to have white space on your page before the first <?php tag in your code or after the final closing tag ?>