Complete the code to set a cookie named "user" with value "Alice".
<?php setcookie("user", [1]); ?>
The setcookie function requires the cookie value as a string, so it must be in quotes.
Complete the code to read the cookie named "user" and store it in the variable $username.
<?php
$username = $_COOKIE[[1]];
?>When accessing a cookie from the $_COOKIE array, the key must be a string in quotes.
Fix the error in the code to set a cookie that expires in 1 hour.
<?php setcookie("session", "abc123", [1]); ?>
The third parameter of setcookie is the expiration time as a Unix timestamp. Use time() + 3600 for 1 hour from now.
Fill both blanks to create a cookie named "theme" with value "dark" that expires in 7 days.
<?php setcookie([1], [2], time() + 7 * 24 * 3600); ?>
The first parameter is the cookie name as a string, the second is the value as a string.
Fill all three blanks to read the cookie "language" safely, providing a default value "en" if it does not exist.
<?php $lang = isset($_COOKIE[[1]]) ? $_COOKIE[[2]] : [3]; ?>
Check if the cookie "language" exists with isset, then read it; otherwise, use the default "en".