What are the implications of using cookies to exclude a specific number generated by rand() in PHP?

When using cookies to exclude a specific number generated by rand() in PHP, the implication is that the exclusion may not be completely effective as the user can easily delete or manipulate the cookie. To solve this issue, a more secure method such as storing the excluded number in a server-side session or database should be used.

// Check if excluded number is set in session
session_start();
if (!isset($_SESSION['excluded_number'])) {
    $_SESSION['excluded_number'] = rand(1, 10); // Generate a random number to exclude
}

// Generate a random number excluding the excluded number
$random_number = rand(1, 10);
while ($random_number == $_SESSION['excluded_number']) {
    $random_number = rand(1, 10);
}

echo "Random number generated: " . $random_number;