A cookie is a small bit of information stored on a viewer's computer by his or her web browser by request from a web page. The information is constantly passed in HTTP headers between the browser and web server; the browser sends the current cookie as part of its request to the server and the server sends updates to the data back to the user as part of its response. In addition to the information it stores, each cookie has a set of attributes: an expiration date, a valid domain, a valid domain path and an optional security flag. These attributes help ensure the browser sends the correct cookie when a request is made to a server.
Syntax:
setcookie(name, value, expire, path, domain);
Example:
setcookie("c_name", "Adam", time()+60);
?>
Retrieve a Cookie:
The $_COOKIE variable is used to retrieve a cookie.
echo $_COOKIE["user"];
?>