dongne1560 2013-10-12 21:33
浏览 48
已采纳

删除cookie(PHP,JS)适用于Firefox,Safari,Opera,但不适用于Chrome

The question basically explains it all, I'm trying to delete the cookie in PHP and also sending JS to delete the cookie as well, not working ONLY in Chrome...

<?php
  unset( $_COOKIE['name'] );
  setcookie('name', '', time() - 3600 ); // empty value and old timestamp
?> 
<script type="text/javascript">
    function deleteCookie( name ) {
       document.cookie = name + '=;expires=Thu, 01 Jan 1970 00:00:01 GMT;';
    }
    deleteCookie('name');

</script>
<a href="cookie.php">cookie</a>

All help is appreciated, thanks!

EDIT: Firebug in Firefox shows no errors, PHP error log shows nothing... the only other thing I can see is that chrome seems to be conserving 1 particular value. name=ABCDE ... if I change it to name=ABC then delete name=ABC it will show name=ABCDE, if I delete name=ABCDE it will still show name=ABCDE

  • 写回答

2条回答 默认 最新

  • dpn4073 2013-10-14 06:30
    关注

    Somewhere during development some wires got crossed, I went into chrome settings and deleted the cookies and all data from my domain:

    https://superuser.com/questions/548096/how-can-i-clear-cookies-for-a-single-site

    and now it works great! I saw other people on forums with this same issue, I encourage you to do the same...

    I don't even send the JS code anymore PHP takes care of it!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 一直显示正在等待HID—ISP