How can conditional statements be used to control when cookies are set in PHP based on the presence of specific values in the GET parameters?

To control when cookies are set in PHP based on the presence of specific values in the GET parameters, you can use conditional statements to check if the desired values exist in the $_GET superglobal array. If the values are present, you can then set the cookies accordingly. This allows you to customize when cookies are set based on the parameters passed in the URL.

if(isset($_GET['param1']) && $_GET['param1'] == 'value1') {
    setcookie('cookie1', 'value1', time() + 3600, '/');
}

if(isset($_GET['param2']) && $_GET['param2'] == 'value2') {
    setcookie('cookie2', 'value2', time() + 3600, '/');
}