Home  >  Article  >  Backend Development  >  How to clear cookies in php

How to clear cookies in php

王林
王林Original
2020-11-04 14:46:021866browse

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);].

How to clear cookies in php

#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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Related articles

See more