What is the difference between using $_COOKIE['userid'] = ""; and setcookie("Cookiename","", 0, "", "URL") to clear cookies in PHP?

When clearing cookies in PHP, using $_COOKIE['userid'] = ""; only clears the cookie value in the current script execution, but the cookie still exists on the client side. On the other hand, setcookie("Cookiename", "", 0, "", "URL") not only clears the cookie value but also sets the expiration time to a past time, effectively deleting the cookie from the client side as well.

// Clearing cookie using setcookie
setcookie("userid", "", time() - 3600, "/", "example.com");