Cookies are just like sessions except they can stay on your browser for up to two weeks. Just like sessions they need to be set before any output is sent to the browser. This code will set a cookie with the name of "TestCookie" with a value of one. The cookie will expire one hour from the time it is set. The time it expiries is in seconds so we have 60seconds X 60minutes = 3600 seconds in one hour. Then you just fill in the directory of the page setting the cookie and the domain the cookie is being sent on.
Cookie variables are set and accessed the same way as sessions. $_COOKIE['TestCookie'] = WHAT YOU WANT IT SET TO; This will change TestCookie to be equal to something else. To access the variable you just call $_COOKIE['TestCookie']