Forum Moderators: coopster
setcookie("cookie1",$value1);
setcookie("cookie2",$value2);
1) Avoid any output statements before setting the second cookie.
2) Use output buffering as described here [de.php.net]:
Cookies are part of the HTTP header, so setcookie() must be called before any output is sent to the browser. This is the same limitation that header() has. You can use the output buffering functions to delay the script output until you have decided whether or not to set any cookies or send any headers.
3) Store both values in an array and store the serialized array in the cookie as mentioned on this [de3.php.net] page:
Cookies names can be set as array names and will be available to your PHP scripts as arrays but separate cookies are stored on the users system. Consider explode() or serialize() to set one cookie with multiple names and values.
$value = array( $value1, $value2 );
setcookie( "mycookie", serialize( $value ) );
and then
$value = unserialize( $_COOKIE['mycookie'] );
echo $value[0];
echo $value[1];