Home > Article > Backend Development > How to clear cookies in php
How to clear cookies in php: Just make sure that the cookie expiration date is in the past, so that you can trigger the browser's deletion mechanism to delete it, such as [setcookie("TestCookie", "", time() - 3600);].
#If you want to delete a cookie, you need to ensure that its expiration date is in the past. Only in this way can the browser's deletion mechanism be triggered.
(Recommended tutorial: java video tutorial)
Example:
Delete the set cookies:
<?php //将过期时间设为一小时前 setcookie("TestCookie", "", time() - 3600); setcookie("TestCookie", "", time() - 3600, "/~rasmus/", ".utoronto.ca", 1); ?>
Related Recommended: php training
The above is the detailed content of How to clear cookies in php. For more information, please follow other related articles on the PHP Chinese website!