duanli8391 2015-07-10 13:20
浏览 11
已采纳

Silex clearCookie不工作?

Trying to use Silex's clearCookie function on the 'ResponseHeaderBag'

The cookie was set something like this, passing an instance of the Cookie class to setCookie:

$response->headers->setCookie(new Cookie(
    $cookieName,
    $value,
    $timeStamp,
    '/',
    $domain,
    false,
    false
));

Notice we're setting values for all the optional parameters.

We're trying to delete the cookie simply using the name parameter:

$responseHeaders->clearCookie($cookieName);

... which doesn't seem to do anything.

  • 写回答

1条回答 默认 最新

  • dongman5539 2015-07-10 13:24
    关注

    The solution was clearCookie also takes several optional parameters. We also had to pass the same values for those optional arguments that matched what we used when we called setCookie!
    Basically the same except we don't need the value or timestamp parameters.

    $responseHeaders->clearCookie(
        $cookieName,
        '/',
        $domain,
        false,
        false
    );
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 vmware exsi重置后的密码
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真
  • ¥15 mars2d在vue3中的引入问题
  • ¥50 h5唤醒支付宝并跳转至向小荷包转账界面