What is the best practice for reloading a page after setting a cookie in PHP?

After setting a cookie in PHP, the best practice for reloading a page is to use the header() function to redirect the user back to the same page. This ensures that the cookie is properly set and available for use on the refreshed page.

<?php
// Set the cookie
setcookie("example_cookie", "cookie_value", time() + 3600, "/");
// Redirect to the same page to reload with the new cookie
header("Location: ".$_SERVER['REQUEST_URI']);
exit;
?>