Saturday, 7 September 2013

Cannot send 'PHPSESSID' via file_get_contents && stream_context_create

Cannot send 'PHPSESSID' via file_get_contents && stream_context_create

I am trying send a http request but I've noticed that when I am trying to
send PHPSESSID as COOKIE I get the warning:
file_get_contents('http://mysite.localhost'): failed to open stream: HTTP
request failed
Code:
$options = array(
'http' => array(
'header' =>
"Content-type: application/x-www-form-urlencoded\r\n".
"Cookie: {$this->COOKIE}\r\n",
'method' => $this->method,
'content' => $this->POST,
),
);
$c = file_get_contents($this->uri, false, stream_context_create($options));
if(!$c)
throw new \Exception("Unable to fetch the request...");
echo $c;
What am I doing wrong?

No comments:

Post a Comment