How can PHP developers address the issue of dynamic IPs when implementing a voting system?

Issue: Dynamic IPs can pose a challenge in a voting system as users may be able to manipulate the system by changing their IP address to vote multiple times. To address this, developers can implement a solution using sessions or cookies to track and limit the number of votes from a single user.

// Start a session to track user votes
session_start();

// Check if the user has already voted
if(isset($_SESSION['voted'])){
    echo "You have already voted.";
} else {
    // Process the vote
    echo "Thank you for voting!";
    
    // Store a flag in the session to prevent multiple votes
    $_SESSION['voted'] = true;
}