← Basics of PHP Cookies
We can add a set of data by array as cookies. Here is a sample code on how to use array as cookies. We will use one sample form to collect user entered details.
<form method=post action=cookies_redirect.php><font face='Verdana' size='2'>
Enter Your Name<input type=text name=name > <br>
Enter Your City Name<input type=text name=city><br>
Enter Your State Name<input type=text name=state><br>
Enter Your Zip Code<input type=text name=zip>
<input type=submit value=Next>
</font>
</form>
We will collect the details and then set the cookies and add them to user computer.
To read the array cookie we will use print_r command of PHP array
if(isset($_COOKIE['Plus2netCookie'])){
print_r($_COOKIE[Plus2netCookie]);
echo "<br><br><font face='Verdana' size='2'>Your name should appear after the welcome message above if cookie is available. </font>";
}else{
echo " No Cookie is set ";
}