在tcp/ip入门经典知道资源流是一层一层的,现在只讨论http那一层的上下文(header那些):
<?php $opts = array( ‘http‘=>array( ‘method‘=>"GET", ‘header‘=>"Accept-language: en\r\n" . "Cookie: foo=bar\r\n" ) ); $context = stream_context_create($opts); /* Sends an http request to www.example.com with additional headers shown above */ $fp = fopen(‘http://localhost/a.php‘, ‘r‘, false, $context); fpassthru($fp); fclose($fp); ?>
在自己机器里面脚本如下:
<?php var_dump($_COOKIE);
当运行脚本时候输出:
原文地址:https://www.cnblogs.com/xuweiqiang/p/10361328.html
时间: 2024-11-05 18:43:56