php 删除set unset删除cookie php
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 删除set unset删除cookie php相关的知识,希望对你有一定的参考价值。
//Update cookie
$cookie_name = 'pontikis_net_php_cookie';
$cookie_value = 'test_cookie_updated_with_php';
setcookie($cookie_name, $cookie_value, time() + (86400 * 30), '/'); // 86400 = 1 day
//Delete cookie
$cookie_name = 'pontikis_net_php_cookie';
unset($_COOKIE[$cookie_name]);
// empty value and expiration one hour before
$res = setcookie($cookie_name, '', time() - 3600);
//read cookies
$cookie_name = 'pontikis_net_php_cookie';
if(!isset($_COOKIE[$cookie_name])) {
print 'Cookie with name "' . $cookie_name . '" does not exist...';
} else {
print 'Cookie with name "' . $cookie_name . '" value is: ' . $_COOKIE[$cookie_name];
}
//create cookie
$cookie_name = 'pontikis_net_php_cookie';
$cookie_value = 'test_cookie_set_with_php';
setcookie($cookie_name, $cookie_value, time() + (86400 * 30), '/'); // 86400 = 1 day
以上是关于php 删除set unset删除cookie php的主要内容,如果未能解决你的问题,请参考以下文章
PHP中unset,array_splice删除数组中元素的区别
(实用篇)PHP中unset,array_splice删除数组中元素的区别
删除由 php unset 创建的数字键
Linux命令之删除变量unset
PHP中unset,array_splice删除数组中元素的区别
unset()