We use the setcookie() function to create and delete cookies as well as to change its value. And it is the same as changing its value as it is creating. Just type the name we have defined in the name of the cookie. The value is changed if the cookie is created if it does not exist.

<?php
setcookie('cookie', 'salute world');
setcookie('cookie', 'hello world');
echo $_COOKIE['cookie'];
?>

The screen will show hello world.