Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What happens if you delete cookie in php?

2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

Php if you delete cookie, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.

In php, you can use the setcookie () function to delete the cookie by setting the second parameter of the function to null, or the third parameter to less than the current time of the system.

Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

When Cookie is created, if its expiration time is not set, its Cookie file will be automatically deleted when the browser is closed. If you want to delete the Cookie file before closing the browser, you need to use the setcookie () function.

There are two ways to delete cookie using the setcookie () function, which will be described in detail below.

Method 1: use the setcookie () function to set the value of Cookie (that is, the second parameter) to null

Running the above code for the first time creates two Cookie; named url and name to run again to view the value of Cookie and clear the value of url in it; the third run can see the result after cleaning. As follows:

/ / first run, first run, set the values of url and name Cookie / / View the value of Cookie in the second run, as follows: Array ([url] = > https://www.php.cn/ [name] = >) clear the value of url / / run Array for the third time ([name] = >)

Method 2: use the setcookie () function to set the expiration time of Cookie (that is, the third parameter) to less than the current time of the system.

The running results are as follows:

/ / first run, first run, set the values of url and name Cookie / / View the value of Cookie in the second run, as follows: Array ([url] = > https://www.php.cn/ [name] = >) clear the value of url / / run Array for the third time ([name] = >)

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report