Reputation: 1
Im having a strange problem.
I have a registration script for a car show's website I manage and for no reason the older code is broken. I know it worked before, but now does not.
I am setting session variables correctly. I am saving an entire Array of variables to the session and I know the session works once the form is submitted as the form reloads to a new page and I display the registration info for confirmation. However, the script then continues to a PayPal page where it takes the user through a payment process. It then redirects back to the site where the registration info is submitted to the MySQL database upon the completion of the payment process.
HOWEVER, when the users return to the confirmation page where the data is submitted, the session variable is completely blank. I have echo'ed all the variables and there's nothing there.
To test where its breaking, I put a link on the page you're taken to after filling out the form linking directly to the confirmation page where the info is dumped to the SQL server. When you link the link, the info is still there. However, if you were to take that same URL and paste it into the address bar (aka NOT using the link), the variables are blank.
So at this point, I am lost as to why the variables are fine when you link and click to the page, but not when you past the same url into the address bar and not click the link. Session is started on EVERY page and all are on the same domain name.
Any help?!
===== EDIT ===== Test Code (to give a rough idea)
How I am setting the session variables. The session_start(); function is called at the loading of every page on this site for continuity across other pages:
$storedVars = array(1 => $name, $email, $state, $year, $make, $model, $generation, $color, $now, $paymentType);
$_SESSION['registration']=$storedVars;
On the confirmation page after PayPal where the information gets sent to the database, the following code is run (again, session_start(); already called):
$storedVars = $_SESSION['registration'];
$name = $storedVars[1];
$email = $storedVars[2];
$state = $storedVars[3];
$year = $storedVars[4];
$make = $storedVars[5];
$model = $storedVars[6];
$generation = $storedVars[7];
$color = $storedVars[8];
$now = $storedVars[9];
The 10th array variable, paymentType, is not needed at this point as its only used for the page after the form is submitted)
When those variables are echo'ed on the confirm page after following through the steps on paypal OR pasting the right URL into the address bar after filling out the form, nothing is there. HOWEVER.. When you click the link on the data validation page that follows after the form is submitted, the variables are still there.
Upvotes: 0
Views: 1495
Reputation: 516
Your last comment makes me believe that your session was set at http://yoursite.com/ and the return url you are sending to PayPal is http://www.yoursite.com/ (or vice versa). "www" is really a subdomain to your base domain and considered to be a different host as far as your browser is concerned.
Long story short, use the following for the return url when setting up your token with paypal:
$_SERVER["HTTP_HOST"] . "/Path/To/PaypalReturnPage.php"
Upvotes: 2