How to delete cookies in php: Just change the expiration date to a point in time in the past, such as [setcookie("user", "", time()-3600);].
Method to delete cookies:
When you need to delete cookies, you should change the expiration date to a point in time in the past.
(Video tutorial recommendation: php video tutorial)
Deleted instance:
<?php // 设置 cookie 过期时间为过去 1 小时 setcookie("user", "", time()-3600); ?>
Create cookie
setcookie() function Used to set cookies.
Note: The setcookie() function must be located before the tag.
Example:
In the following example, we will create a cookie named "user" and assign it the value "runoob". We also specify that this cookie expires after one hour:
<?php setcookie("user", "runoob", time()+3600); ?> <html> .....
Related recommendations: php training
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!