PHP Cookies

In this tutorial you will learn about the PHP Cookies and its application with practical example.

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.

Example:

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.

 

In this tutorial we have learn about the PHP Cookies and its application with practical example. I hope you will like this tutorial.