What is the correct way to set a cookie with an expiration date in PHP?
Setting a cookie with an expiration date in PHP allows you to control how long the cookie will persist on the user's browser. To set a cookie with an expiration date, you need to specify the expiration time in seconds from the current time. This can be achieved by adding the expiration time to the current timestamp using the `time()` function.
// Set a cookie with an expiration date of 1 day from the current time
$expiration = time() + 86400; // 86400 seconds = 1 day
setcookie("cookie_name", "cookie_value", $expiration);