What are common methods for preventing multiple votes in a PHP-based survey on a website?

To prevent multiple votes in a PHP-based survey on a website, you can use techniques such as setting cookies, tracking IP addresses, or requiring users to log in before voting. These methods help ensure that each user can only submit one vote.

// Example using cookies to prevent multiple votes
if(isset($_COOKIE['voted'])){
    echo "You have already voted.";
} else {
    // Process the vote
    setcookie('voted', 'true', time() + (86400 * 30)); // Cookie expires in 30 days
}