How can PHP cookies be effectively utilized to prevent multiple clicks on a "like" button within an HTML page?

To prevent multiple clicks on a "like" button within an HTML page, PHP cookies can be utilized to track whether a user has already liked the content. When the user clicks the "like" button, a cookie can be set to indicate that the action has been taken. Subsequent clicks can then be ignored if the cookie is present.

<?php
// Check if the like button has been clicked
if(isset($_COOKIE['liked'])) {
    echo "You have already liked this content.";
} else {
    // Process the like action
    setcookie('liked', '1', time() + 3600); // Set a cookie to indicate that the content has been liked
    echo "Thank you for liking this content!";
}
?>