views:

395

answers:

0

Hey I have a script that POSTs all data sent to it directly to another page.

On the second page, the script calls for several variables set as $var = $_COOKIE['name'];

The problem is that the script seems to not set the variables that read data based on cookies any time the script is called from a background cURL/Snoopy POST.

How can my script read the cookie data even when the visitor doesn't actually visit that page; meaning that the data is just posted to that page in the background through API.

Everything else besides cookie based variables seems to work.

Example:

$postdata = http_build_query(
    array(
        'var1' => 'some content',
        'var2' => 'doh'
    )
);
$opts = array('http' =>
    array(
        'method'  => 'POST',
        'header'  => 'Content-type: application/x-www-form-urlencoded',
        'content' => $postdata
    )
);
$context  = stream_context_create($opts);
$result = file_get_contents('http://www.unreal-deals.com/ebook/tests/post-redirect-htaccess.php', false, $context);

echo $result;

And on my page http://www.unreal-deals.com/ebook/tests/post-redirect-htaccess.php, the code to read is:

echo 'hey';
echo $_COOKIE['mycookie'];

However, it only grabs 'hey', and doesnt grab the cookie data which is in fact set on my computer as of right now.

Why doesn't it read the cookie, and how can I make it read the cookie?

Thanks