What are the advantages and disadvantages of using sessions or cookies to prevent data duplication in PHP?

When preventing data duplication in PHP, using sessions is more secure as the data is stored on the server side. However, sessions can be slower due to the need to communicate with the server for each request. On the other hand, cookies are faster as the data is stored on the client side, but they are less secure as they can be tampered with.

// Using sessions to prevent data duplication
session_start();

if (!isset($_SESSION['visited'])) {
    // Code to prevent data duplication
    $_SESSION['visited'] = true;
}