Google News
logo
PHP Program to Delete a cookie
To delete a cookie, you can set the cookie's expiration time to a time in the past. Here's an example PHP program to delete a cookie :
Program :
<?php
// Set the cookie value
setcookie('my_cookie', 'cookie_value', time() + 3600);

// Delete the cookie by setting its expiration time to the past
setcookie('my_cookie', '', time() - 3600);
?>
This program first sets a cookie with the name `my_cookie` and the value `cookie_value`, with an expiration time of one hour in the future (`time() + 3600`).

Then, the program deletes the cookie by setting its expiration time to one hour in the past (`time() - 3600`). When the browser receives this cookie, it will immediately expire and be deleted.