发布网友 发布时间:2022-04-28 04:37
共7个回答
懂视网 时间:2022-04-28 08:58
php删除cookies的方法:1、使用“setcookie('cookiename', '')”方法将cookie的值设置为空;2、通过“setcookie('cookiename','',time()-3600);”方法。
推荐:《PHP视频教程》
php删除/清除cookie的两种方法
将cookie的值设置为空,即:setcookie('cookiename', '')或者setcookie(cookiename, NULL);
将cookie的过期时间设置为过去,即:setcookie('cookiename','',time()-3600);
方法一:将cookie的值设置为空
<?php setcookie ( "cookie_user", "test", time () + 60 * 60 * 24 * 30 ); setcookie ( "cookie_pass", md5 ( "test" ), time () + 60 * 60 * 24 * 30 ); function logout() { setcookie ( "cookie_user", "", time () + 60 * 60 * 24 * 30 ); setcookie ( "cookie_pass", "", time () + 60 * 60 * 24 * 30 ); } /* http://www.manongjc.com/article/1253.html */ logout (); echo $_COOKIE ['cookie_user'] . "<br />"; echo "You have successfully logged out."; ?>
第二种方法:将cookie的过期时间设置为过去
<?php setcookie ( "cookie_user", "test", time () + 60 * 60 * 24 * 30 ); setcookie ( "cookie_pass", md5 ( "test" ), time () + 60 * 60 * 24 * 30 ); function logout() { setcookie ( "cookie_user", "test", time () - 100 ); setcookie ( "cookie_pass", md5 ( "test" ), time () - 100 ); } logout (); echo $_COOKIE ['cookie_user'] . "<br />"; echo "You have successfully logged out."; ?>
热心网友 时间:2022-04-28 06:06
删除cookie 的方法有两种热心网友 时间:2022-04-28 08:59
将cookie的过期时间设置为负值。
如:
setcookie("id","root",time()-10);
热心网友 时间:2022-04-28 10:50
浏览器设置有清除cookie热心网友 时间:2022-04-28 12:58
setcookie("users","OKadmin",time()-3600)热心网友 时间:2022-04-28 15:23
unset($_COOKIE)热心网友 时间:2022-04-28 18:04
两种方法: