How to create a cookie in PHP

How to create a cookie in PHP
setcookie("<cookie_name>", "<cookie_value>",<time is will expire>);

setcookie("username", "$username", time()+36000000);

Note that setcookie must be called before any text is echoed/printed to screen since it is passed in the header and header information must be the first itam that is sent