PHP-使用file_get_contents发送cookie [英] PHP - Send cookie with file_get_contents

查看:236
本文介绍了PHP-使用file_get_contents发送cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

PHP手册上的示例显示了如何使用流上下文发送cookie.这是摘录:

The example on PHP manual shows how you can use stream contexts to send a cookie. Here is the excerpt:

// Create a stream
$opts = array(
  'http'=>array(
    'method'=>"GET",
    'header'=>"Accept-language: en\r\n" .
              "Cookie: foo=bar\r\n"
  )
);

$context = stream_context_create($opts);

// Open the file using the HTTP headers set above
$file = file_get_contents('http://www.example.com/', false, $context);

您如何发送多个cookie?像#1或#2,还是什么?

How do you send more than one cookie? Like #1 or #2, or what?

#1

"Cookie: user=3345&pass=abcd\r\n"

#2

"Cookie: user=3345\r\n" . 
"Cookie: pass=abcd\r\n"

推荐答案

#3

Cookie: user=3345; pass=abcd

这篇关于PHP-使用file_get_contents发送cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆