Yes i have tried the above. It is working if you write test.php as follows:
<?php
setcookie ("cookie", "test"

;
header('Location: test2.php');
?>
Where you go wrong is in defining the domain as localhost.
The next will set an cookie for the next hour for the domain you are currently on.
<?
setcookie ("cookie", "test",time()+3600, "/"

;
header('Location: test2.php');
?>
To delete the cookie, set the time in the past: (Use the same parameters as you used to set the cookie)
<?
setcookie ("cookie", "test",time()-3600, "/"

;
header('Location: test2.php');
?>
Good luck mcvdmvs
-- "It never hurts to help" -- Eek the Cat