I have the following script, and it works on my development server (Wampserver2), but on the production server (Linux), the cookies I'm trying to send in the HTTP header don't seem to make the receiving script use them.
Initially, on Wampserver2, I had a problem, and it was that I had to have a User-Agent string in the header, but I have no clue what is going on for the Linux server.
I have tried to change the line endings in the header from \r\n to \n, so that isn't going to make a difference, in case that was what you are thinking.
Please let me know if you have an answer.
The code:
Code:<?php defined('SYSPATH') OR die('No direct access allowed.'); if(isset($_COOKIE['bwd_data']) && isset($_COOKIE['bwd'])){ $cookie_val = $_COOKIE['bwd_data']; $cookie_val2 = $_COOKIE['bwd']; $opts = array( 'http'=>array( 'method'=>"GET", 'header'=> "Host: www.mysite.com\r\n" . "User-Agent: " . $_SERVER['HTTP_USER_AGENT'] . " \r\n" . "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 \r\n" . "Accept-language: en-us,en;q=0.5\r\n" . //"Accept-Encoding: gzip,deflate\r\n" . "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n" . "Keep-Alive: 300\r\n" . "Connection: keep-alive\r\n" . "Referer: http://www.mysite.com/\r\n" . "Cookie: bwd=" . $cookie_val2 . "; " . "bwd_data=" . $cookie_val . "\r\n" ) ); $context = stream_context_create($opts); echo(file_get_contents(url::site('httperrors','http'), FALSE , $context)); }else{ echo(file_get_contents(url::site('httperrors','http'))); } ?>








Bookmarks