1 <?php 2 parse_str($_SERVER["QUERY_STRING"]); 3 4 function deleteCookie($value, $name) 5 { 6 setcookie($name, "deleted", time() - 86400, '/'); 7 } 8 9 if ($queryfunction == "deleteCookies") { 10 array_walk($_COOKIE, deleteCookie); 11 echo "Deleted all cookies"; 12 return; 13 } 14 15 if ($queryfunction == "setFooCookie") { 16 setcookie("foo", "awesomevalue", time() + 86400, '/'); 17 echo "Set the foo cookie"; 18 return; 19 } 20 21 if ($queryfunction == "setFooAndBarCookie") { 22 setcookie("foo", "awesomevalue", time() + 86400, '/'); 23 setcookie("bar", "anotherawesomevalue", time() + 86400, '/'); 24 echo "Set the foo and bar cookies"; 25 return; 26 } 27 28 // Default for any other string is echo cookies. 29 function echoCookie($value, $name) 30 { 31 echo "$name = $value\n"; 32 } 33 34 function echoAllCookies() 35 { 36 echo "Cookies are:\n"; 37 array_walk($_COOKIE, echoCookie); 38 } 39 40 ?> 41