This code shouldn't work, because the cookie data should sent with the headres, before any other output.
<html>
<body>
text before setcookie
<?php
setcookie( "meaningoflife", "42", time()+42000 );
?>
</body>
</html>
But why I get the php from a browser, it will be set. Why ? My PHP version is 5.3.6, apache 2.2.20 on a Mac OS X machine.