<? PHP header ("Content-Type: text/html; charset = UTF-8"); // demonstrate how to update the cookie information setcookie ("password", "11111", time () + 300); echo "file updated successfully! ";?>
<? PHP // specify to delete a key-Value Pair // setcookie ("name", "", time ()-200); // echo "name deleted successfully! "; // Delete all cookies. If the cookie file does not have a record, the cookie file will also be // deleted foreach ($ _ cookie as $ key => $ Val) {setcookie ($ key, "", time ()-100);} echo "successfully deleted all localhost cookies! ";?>
<? PHP header ("Content-Type: text/html; charset = UTF-8 "); // demonstrate how to create cookie information // Save the user name and password to the client's cookie // This function is used to save the cookie, the first // parameter represents the parameter's key value, the second value indicates the cookie value. // 3 indicates the expiration time, in seconds. Setcookie ("name", "shunping", time () + 3600); setcookie ("password", "12345", time () + 3600); echo "saved successfully! ";?>
<? PHP header ("Content-Type: text/html; charset = UTF-8"); // demonstrate how to obtain cookie information echo "<PRE> "; // obtain all cookieprint_r ($ _ cookie); echo "</PRE> "; // obtain the value of the specified key $ name =$ _ cookie ['name']; echo "name = ". $ name;?>