Using good development practices, should one check for the existence of the setcookie after setting it, or is it known to be set 100%? Thank you.
<?php
require "includes/settings.php";
require "functions/php_function_library.php";
$item_id = $_REQUEST['item_id'];
$item_qty = $_REQUEST['quantity'];
echo $item_id;
echo $item_qty;
$cookie_guid = guid();
setcookie("anonymous_cart", $cookie_guid);
#check that the cookie I just set exists?
#insert new cart record into DB
...
?>
Just check the return value, if false it failed. Otherwise you can consider it set (I’ve never seen it not get set in that case).
However if the cookie being set is of critical importance, then checking it can’t hurt (much).
EDIT
For those pointing out that this does not guarantee the cookie was accepted, I agree and did not say that it does (how could it? The client hasn’t even received the cookie yet). It simply means that the cookie was set. Which is what op asked.