0

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);
}

Edited by veledrom: .

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by veledrom
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.