Home >Backend Development >PHP Problem >How to clear cookies in php

How to clear cookies in php

Guanhui
GuanhuiOriginal
2020-05-08 17:12:463795browse

How to clear cookies in php

How to clear cookies in php

1. Use the function "setcookie()" to set the cookie value to empty or NULL;

//将cookie值设置为空
setcookie ("name", "");
//或者将cookie值设置null
setcookie ("name", null);

2. By setting the cookie expiration time to the past time, just set the third parameter of "setcookie()" to "time()-1".

setcookie ("name", "xiaoming", time() - 1);

Recommended tutorial: "PHP Tutorial"

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