What is the role of cookies in PHP web development and how can they be used to store user data?

Cookies in PHP web development are used to store small pieces of data on the user's computer. They can be used to store user preferences, track user sessions, and personalize the user experience. To store user data in cookies, you can set a cookie using the `setcookie()` function in PHP with a name and value.

// Store user data in a cookie
$userData = array(
    'username' => 'john_doe',
    'email' => 'john.doe@example.com'
);

$encodedData = json_encode($userData);

setcookie('user_data', $encodedData, time() + 3600, '/');