I was trying to figure out how to store an array of data into a single cookie, and by searching these forums I found out how. Although, when I went to test it, I got an error I'm unfamilyar with...
The code is:
<?
if ( $step == NULL ) {
/* SET COOKIE */
$setcookie_var1 = "Something";
$setcookie_var2 = "2.50";
$setcookie_var3 = "CatA";
setcookie("testcookie",$setcookie_var1.":".$setcookie_var2.":".$setcookie_var3,(time()+604800),"/","",0);
print '<p><a href="testcookie.php?step=2">Next step</a>';
}
if ( $step == "2" ) {
$value_delimiter = ":";
$the_cookie_mon = $HTTP_COOKIE_VARS["testcookie"];
$array = explode("$value_delimiter",$the_cookie_mon);
}
?>
The error I get is:
Warning: Cannot add header information - headers already sent by (output started at /usr/local/psa/home/vhosts/codercastle.com/httpdocs/testcookie.php:4) in /usr/local/psa/home/vhosts/codercastle.com/httpdocs/testcookie.php on line 8
Next step
Thanks