PHP Cookies

PHP Cookies enables the web programmer to store information about the site visitor on the client computer and can be retrieve again to track the visitor. PHP Cookies are stored in text files.

Creating PHP Cookies:

Cookies can be created using the setcookie() function. The syntax is as follows:

Param Description
name Name of the cookie.
value Value of the cookie.
expiration Time when this cookie will expire. Unix timestamp is used here.


Retrieve Cookies:

Cookies can be retrieved using the $_COOKIE or the $_HTTP_COOKIE_VARS arrays.

Delete Cookies:

To delete a cookie from a client computer, simply use the setcookie() function and set the expiration time as a time in the past.