Cookie is a very important part in Internet. PHP supports HTTP cookies. Using cookie we can store data into a remote browser. We can set the cookies using either setcookie() or setrawcookie() function. Cookies belong to the HTTP header that's why setcookie() must be called before any output is sent to the browser like header() function.
Any cookie which is sent from client side will automatically be included into a $_COOKIE auto global array. If more than one value has to be stored then we need to declare the $_COOKIE as associative array.
$var="This is a test of cookie";
<form action="cookie-2.php" method="post">
Name<input type="text" name="name"/>
Enter an input and hit the return key, and the output will be as follows:
roseindia: This is a test of cookie
Recommend the tutorial