Re: SV: [PHP] Send a cookie with a file_get_contents( ) request?
| From: | Per Jessen | Date: | Sun, 10 Aug 2008 08:04:48 +0000 |
| Subject: | Re: SV: [PHP] Send a cookie with a file_get_contents( ) request? | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-277944@lists.php.net to get a copy of this message | ||
Anders Norrbring wrote:
> Thanks Per,
> I think so too, I glanced it, but unfortunately I have no idea
> whatsoever about *how* to do it... So, if anyone have suggestions, or
> concrete examples, please do share!
>
> Anders.
I did play around with it once, but I don't have any actual code to
share. Try this though:
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: en\r\n".
"Cookie: foo=bar\r\n"
)
);
$context = stream_context_create($opts);
$result=file_get_contents( <url>, FILE_TEXT, $context );
/Per Jessen, Zürich