How to clear cookies in php

王林
Release: 2023-03-07 09:32:01
Original
1882 people have browsed it

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

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!

Related labels:
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