The code you posted originally will create multiple cookies. What are you trying to do? Store a history of what content user's have looked at?
If so, why not store either a serialised array, or a comma separated list?
$data = serialize(array(1, 2, 3, 4);
setcookie('history', $data, ...);
$data = implode(',', array(1, 2, 3, 4));
setcookie('history', $data, ...);