1

So http://example.com/test.php generates a PHP Session cookie for the client.

So I do

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

But it returns me only the HTML source (no headers).

How do I get the PHPSESSID that was set by that page? I don't want to use CURL or addons.

Thanks!

James Chen
  • 33
  • 4

1 Answers1

0

You can use the magic variable $http_response_header for that.

Use it this way:

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

Find more information in the php manual for http_response_header.

Roman
  • 2,530
  • 2
  • 27
  • 50