Home  >  Article  >  Backend Development  >  How to delete cookies in php

How to delete cookies in php

藏色散人
藏色散人Original
2021-05-12 10:05:202737browse

How to delete cookies in php: first create a new php file; then use the setcookie() function to create a cookie named name; finally use the setcookie() function to expire the cookie setting to delete the cookie.

How to delete cookies in php

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

Create a new php file and name it test.php. Used to explain how to delete cookies in PHP.

How to delete cookies in php

In the test.php file, use the setcookie() function to create a cookie named name.

How to delete cookies in php

In the test.php file, use echo to output the currently set cookie value, run the test.php file, and view the results.

How to delete cookies in php

In the test.php file, use the setcookie() function to expire the above cookie setting, that is, delete the cookie.

How to delete cookies in php

In the test.php file, use the if statement to determine whether the cookie has been successfully deleted, and use echo to output the result. [Recommended learning: "PHP Video Tutorial"]

How to delete cookies in php

Open the test.php file in the browser to view the results.

How to delete cookies in php

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