Make sure the HTTP headers are not sent already at the point you want to set the cookie. Here’s how you can test that:
function set_cookie() {
var_dump(headers_sent()); // should be bool(false)
...
Turning WP_DEBUG
on in your config.php file may help also while debugging.
By the way, you really should be doing some filtering on $_GET['id']
. This variable could contain anything. Casting it to a (positive) integer should go a long way:
$referrerID = absint($_GET['id']); // Note: absint() is a WP function