Hi,

If you set $dowhat to "Clean", I get this error message : Warning: setcookie() expects parameter 1 to be string, array given in C:\wamp\www\.... which is line 18.

However, if I remove unserialize() function from same line, I get Warning: Cookie names cannot contain any of the following '=,; \t\r\n\013\014' in C:\wamp\www\... .

I just want to remove the cookie, that's all.

Thanks in advance

$value = $_POST["value"];
$dowhat = $_POST["dowhat"];

if($dowhat == "Add"){
	$_SESSION["SITE"]["Favorite"][$value] = true;
	setcookie("MyFavoriteCookie", serialize($_SESSION["SITE"]["Favorite"]), time() + 3600);
	
} else if($dowhat == "Remove"){
	unset($_SESSION["SITE"]["Favorite"][$value]);
	setcookie("MyFavoriteCookie", serialize($_SESSION["SITE"]["Favorite"]), time() + 3600);

} else if($dowhat == "List"){
	echo "<pre>";
	print_r(unserialize($_COOKIE["MyFavoriteCookie"]));
	
} else if($dowhat == "Clean"){
	unset($_SESSION["SITE"]["Favorite"]);
	setcookie(unserialize($_COOKIE["MyFavoriteCookie"]), "", time() - 3600);
}

Why don’t you trust the message ? Array given ?

Found it, I have to use addslashes(serialize(....... and revert

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.