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

How to clear all cookies in php

藏色散人
Release: 2023-03-08 14:16:02
Original
3768 people have browsed it

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);
}
?>
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template