+ -
当前位置:首页 → 问答吧 → 为什么种不了COOKIE 过来看看啊!新手勿扰

为什么种不了COOKIE 过来看看啊!新手勿扰

时间:2011-10-03

来源:互联网

  1. <?php
  2. function wfopen($url,$post='',$cookie='',$timeout=30) {
  3. $matches = parse_url($url);
  4. $out = "POST {$matches['path']} HTTP/1.0\r\n";
  5. $out .= "Accept: */*\r\n";
  6. $out .= "Accept-Language: zh-cn\r\n";
  7. $out .= "Content-Type: application/x-www-form-urlencoded\r\n";
  8. $out .= "User-Agent: $_SERVER[HTTP_USER_AGENT]\r\n";
  9. $out .= "Host: {$matches['host']}\r\n";
  10. $out .= 'Content-Length: '.strlen($post)."\r\n";
  11. $out .= "Connection: Keep-Alive\r\n";
  12. $out .= "Cache-Control: no-cache\r\n";
  13. $out .= "Cookie: $cookie\r\n\r\n";
  14. $out .= $post;
  15. $socket = @fsockopen($matches['host'],80,$errno,$errstr,$timeout) or die("$errstr($errno)");
  16. @fwrite($socket,$out);
  17. $header = $data = "";
  18. while($infos = trim(fgets($socket,4096))) {
  19. $header.=$infos;
  20. }
  21. while(!feof($socket)) {
  22. $data .= fgets($socket,4096);
  23. }
  24. return $data;
  25. }
  26. echo wfopen('http://localhost/te.php','id=5');
  27. ?>
复制代码


  1. <?php
  2. if(!empty($_POST['id'])) {
  3. echo setcookie('clientAuth','123',time()+3600,'/')  ? 1 : 0 ;
  4. }
复制代码

作者: haowei4032   发布时间: 2011-10-03

顶一下!

作者: haowei4032   发布时间: 2011-10-03

回复 haowei4032


    没人我就再顶

作者: haowei4032   发布时间: 2011-10-03

回复 haowei4032


    还是没有人来帮忙呀!

作者: haowei4032   发布时间: 2011-10-03