This chapter provides tutorial examples and notes about cookie. Topics include understanding of the cookie concept; sending cookies with the setcookie() function; receiving cookies with the $_COOKIE array; enabling output buffering; creating persistent cookies; specifying cookie domain and path.
setcookie() must be called before any output to the HTTP response. The main reason is that
PHP is not buffering the HTTP response. But you can alter this behavior by using the ob_start() functions.
A persistent cookie is stored in a cookie file on the browser's local machine.
A persistent cookie can have an expiration time expressed in number of seconds since epoch.
Web browser will only send back a cookie when both domain and path match the requested domain and path.
To make a cookie available for all sub domains of a top level domain, set the domain property
to the top level domain name.