if(isset($_COOKIE['name'])) { $username = $_COOKIE['name']; echo "Welcome back, $username!"; }
setcookie('name', 'John Doe', time() + 3600); // expires in 1 hourIn this example, we are setting a cookie named 'name' with the value 'John Doe'. The third argument specifies when the cookie should expire. Here, we set it to expire in 1 hour. Package library: The PHP Input Cookie is a part of the PHP core library and does not require any external packages or libraries.