I have a strange problem with PHP script and sending data by POST.
Script source where I receive POST data:
<?php
print_r($GLOBALS);
?>
Script where I send POST data:
<?php
$url = 'http://server.com/script.php';
$data = array(
"request" => '
{
"variable": "some data"
}'
);
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded
",
'method' => 'POST',
'content' => http_build_query($data),
),
);
$context = stream_context_create($options);
echo $result = file_get_contents($url, false, $context);
?>
When I call this script first time it return:
Array ( [GLOBALS] => Array *RECURSION* [_POST] => Array ( ) [_GET] => Array ( ) [_COOKIE] => Array ( ) [_FILES] => Array ( ) )
When I repeat query it's OK - Array show POST data. After a few minutes it is again empty.
I tried set different settings in .htaccess file, but it does not help.
PS. Same script on other server works great.
Do you have any ideas?