duangai9678
2017-12-11 06:54
浏览 134
已采纳

如何在php中删除浏览器的所有cookie

consider i have three websites in a different server namely example1.com,example2.com,example3.com

i have tried to clear all the cookies when i click the particular logout page.But, it clear only the current page cookies.

i opened all these websites in the browser ..and now when i logout from the example1.com it should clear all the cookies of the browser whichever has been set previously...

Thanks in Advance.

My code::

if (isset($_SERVER['HTTP_COOKIE'])) {
    $cookies = explode(';', $_SERVER['HTTP_COOKIE']);
    foreach($cookies as $cookie) {
        $parts = explode('=', $cookie);
        $name = trim($parts[0]);
        setcookie($name, '', time()-1000);
        setcookie($name, '', time()-1000, '/');
    }
}

图片转代码服务由CSDN问答提供 功能建议

考虑我在不同服务器中有三个网站,即example1.com,example2.com,example3.com

当我点击特定的退出页面时,我试图清除所有的cookie。但是,它只清除了当前的页面cookie。

我打开了所有这些网站 在浏览器..现在当我从example1.com注销时,它应该清除浏览器中以前设置的所有cookie ...

先谢谢。

我的代码::

  if(isset($ _ SERVER ['HTTP_COOKIE'])){
 $ cookies = explode(  ';',$ _SERVER ['HTTP_COOKIE']); 
 foreach($ cookies as $ cookie){
 $ parts = explode('=',$ cookie); 
 $ name = trim($ parts [0  ]); 
 setcookie($ name,'',time() -  1000); 
 setcookie($ name,'',time() -  1000,'/'); 
} 
} 
 <  / code>  
 
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题