I have written a simple code in page test_cookie.php to work with cookies.
if(isset($_GET['data'])) {
setcookie('test_cookie', $_GET['data'], time()+60*60*24*30);
}
echo 'Cookie name is: ' . $_COOKIE['test_cookie'];
Now once cookie is set to something, and I set the value to something else (using $_GET), then the content value doesn't change quickly. I have to refresh it again, if a new value comes.
Here is a picture example: