$value){etCookie($key,"",time()-60);}" Just cookies."/> $value){etCookie($key,"",time()-60);}" Just cookies.">

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

How to clear all cookies in php

藏色散人
藏色散人Original
2021-03-08 11:11:113726browse

php method to clear all cookies: first create a PHP sample file; then pass "foreach($_COOKIE as $key=>$value){etCookie($key,"",time()-60 );}" Just delete multiple cookies.

How to clear all cookies in php

#The example in this article describes the simple implementation method of deleting cookies in batches in PHP.

The code is as follows:

<?php
//删除单个cookie:键值设置为空、时间设置为过期了的时间
setCookie("name","",time()-60);
//删除多个cookie,采用遍历数组方式
foreach($_COOKIE as $key=>$value){
 setCookie($key,"",time()-60);
}
?>

Knowledge points: If all cookies of a website are deleted, the file that saves the cookies of the website will also be deleted; if only one of them is deleted cookie, only the cookie information in the file is deleted.

[Recommended: "PHP Video Tutorial"]

The above is the detailed content of How to clear all 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