Cookies in PHP
Cookies are small text files that are stored on a user's computer. PHP provides built-in functions to set, retrieve, and delete cookies.
Example:
php
// set a cookie
$name = "John";
setcookie("name", $name, time() + (86400 * 30), "/"); // expires in 30 days
// retrieve a cookie
if (isset($_COOKIE["name"])) {
echo "Hello " . $_COOKIE["name"];
}
// delete a cookie
setcookie("name", "", time() - 3600, "/");
No comments:
Post a Comment