PHP - Chapter 5 - Cookies and Sessions
PHP - Chapter 5 - Cookies and Sessions
<?php
if(count($_COOKIE) > 0) {
echo "Cookies are enabled.";
} else {
echo "Cookies are disabled.";
}
?>
</body>
</html>
15 Sessions and Cookies management i
n PHP
Removing Cookies
Cookies can be deleted by calling the
setcookie() function with the cookie name and
any value (such as an empty string) with
expiration date set in the past,
<?php
// Deleting a cookie
setcookie("username", "", time()-3600);
?>
<?php
// Starting session
session_start();
?
26 Sessions and Cookies management i
n PHP