doujiexin1136 2018-04-06 03:42
浏览 131
已采纳

在响应有效负载中查找HTTP_COOKIE的来源?

The following code correctly identifies a properly formed payload and sends a 200 response.

if($signature == $authKey)
{
    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, '/');
        }
    }
    http_response_code(200);
    XeroWebHookHandler::handlePayload($rawPayload);
}

The endpoint however, won't accept a HTTP response containing a cookie.

The above code is giving me the following response Response contained a cookie.

My service is hosted on an AWS EC2 instance running a standard Ubuntu server hosting apache.

What methods can I use to correctly identify what might be setting a HTTP_COOKIE variable. Alternatively, am I clearing it correctly?

  • 写回答

1条回答 默认 最新

  • doujianjian2060 2018-04-06 05:50
    关注

    I found it. The answer helped in my specific case, but I will share it in case anyone else has the same issue.

    Session cookies are the issue.

    session_destroy();
    setcookie("PHPSESSID", "", time()-3600, "/");
    

    I found that session_destroy() alone left some crumbs.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化