Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
254 views
in Technique[技术] by (71.8m points)

php - Send cookie with file_get_contents

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
" .
              "Cookie: foo=bar
"
  )
);

$context = stream_context_create($opts);

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

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

#1

"Cookie: user=3345&pass=abcd
"

#2

"Cookie: user=3345
" . 
"Cookie: pass=abcd
"
question from:https://stackoverflow.com/questions/3431160/send-cookie-with-file-get-contents

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

#3

Cookie: user=3345; pass=abcd

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...