Here's the syntax:
## Cookie expires with browser session ##
setcookie ("username", $value);
## Cookie expires at timeout ##
$time = time()+3600; //1 hour
setcookie ("username", $value, $time);
## Cookie will be enabled for whole domain with subdirs ##
setcookie ("username", $value, $time, "/");
## Once set, cookie will be accessible in $_COOKIE['cookiename'], and may be used as a value. ##
$username = $_COOKIE['username'];
This is described in detail at php.net:
http://www.php.net/manual/en/function.setcookie.php
knutm