【问题标题】:Get the new PHPSESSID from file_get_contents result (PHP) [duplicate]从 file_get_contents 结果(PHP)中获取新的 PHPSESSID [重复]
【发布时间】:2017-02-15 17:10:38
【问题描述】:

所以http://example.com/test.php 为客户端生成了一个PHP Session cookie。

所以我愿意

file_get_contents("http://example.com/test.php");

但它只返回 HTML 源代码(没有标题)。

如何获取该页面设置的 PHPSESSID?我不想使用 CURL 或插件。

谢谢!

【问题讨论】:

    标签: php session cookies file-get-contents


    【解决方案1】:

    您可以为此使用魔术变量$http_response_header

    这样使用:

    file_get_contents("http://example.com");
    var_dump($http_response_header);
    

    http_response_header 的 php 手册中查找更多信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-12-30
      • 2019-05-17
      • 1970-01-01
      • 1970-01-01
      • 2018-03-13
      • 2014-06-17
      • 1970-01-01
      相关资源
      最近更新 更多