How can PHP be used to set a cookie for the "Remember me" functionality?

To set a cookie for the "Remember me" functionality in PHP, you can use the setcookie() function with appropriate parameters such as the cookie name, value, expiration time, and path. This cookie can store a token or user ID to identify the user when they return to the website.

// Set a cookie for "Remember me" functionality
$cookie_name = "remember_me";
$cookie_value = "user_id_or_token";
$expiration = time() + (86400 * 30); // 30 days
$cookie_path = "/";
setcookie($cookie_name, $cookie_value, $expiration, $cookie_path);