Home  >  Article  >  Backend Development  >  What to do if PHP fails to clear cookies

What to do if PHP fails to clear cookies

藏色散人
藏色散人Original
2021-11-16 09:53:102029browse

php fails to clear cookies because the path parameter of the cookie does not correspond. The solution is to modify the deletion code to "setcookie($key,"",time()-36000,'/');" .

What to do if PHP fails to clear cookies

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

What should I do if php fails to clear cookies?

The reason why php cookie cannot be deleted

Cookie can be deleted through setcookie(name, value, expiration, path, host, secure, httponly);

is guaranteed If the cookie names are the same, if they still cannot be deleted, it means that the path parameters of the cookies do not correspond.

setcookie($key,$value,time()+36000,'/');

The slash behind it indicates the path, which must be consistent.

Recommended learning: "

PHP Video Tutorial

"

The above is the detailed content of What to do if PHP fails to clear cookies. 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