PHP Cookies

A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user’s computer. Each time the same computer requests a page with a browser, it will send the cookie too. With PHP, you can both create and retrieve cookie values.

Create Cookies

setcookie() method contains different parameters but in the below example we will only use 4 parameters, Cookie Name, Cookie Value, Time in Seconds and Path.



Read Cookie

As php have different Global arrays like $_POST, $_GET and etc. same PHP contains $_COOKIE array to access/set cookies values.


	//read the cookie data
		echo $_COOKIE['color'];
		echo 'No Cookie Found';