PDA

View Full Version : Cookie Weirdness



AppsRU
01-14-2013, 04:15 AM
I'm having a strange problem with cookies.

I'm setting them up so people will store a file name in one and it's title in another, pay at paypal and get the product on return. Pretty straight forward.

Before going live I've created a substitute page on another domain to simulate paypal, this just leads directly back to the download page where the cookies are read.

buy.php sets the cookies
download.php reads the cookies
paygateway.php is on another domain and simply links back to download.php

When I test this download.php isn't reading the cookies.

What's weird is in buy.php I have a link to paygateway.php and download.php. When I go to paygateway.php then back to download.php I see nothing however after that if I open download.php from buy.php I see the cookies.

Pages are as follows

buy.php



if($_POST){

$dlFile = $_POST["item"];
$dlFileName = $_POST["itemname"];
setcookie("zip", "$dlFile", time()+3600);
setcookie("displayName", "$dlFileName", time()+3600);

if($_COOKIE['zip']){
echo "Click here to purchase <a href='http://www...pay domain...com/paygateway.php'><h1>".
$_COOKIE['displayName'].
"</h1></a><br><a href='download.php'>Direct</a>";
} else {
echo "No product selected. Make sure you have cookies enabled";
}
}


paygateway.php

<a href="http://www....first domain....com/download.php">Download</a>


download.php




echo $_COOKIE['zip']."<br>".$_COOKIE['displayName'];



You can see this in action at http://www.ineedplr.com/index22.php when you select a product and click the buy button.

I had planned to do this using SESSION but when I got no readout of the two variables I thought I wasn't doing it right so used cookies instead. After coming across this problem I'm thinking the problem wasn't with session variables...

Any ideas?