Im trying to figure out how to use a php $_SESSION
value. The situation is:
- Main HTML site has an
<iframe>
that loads products.php Within products.php a form submits and saves the two values below:
$_SESSION["subtotal"] = $_POST['SUBT'];
$_SESSION["tax"] = $_POST['TAX'];
These work well I can echo them no problem (within that page)
This page replaces products.php with confirmation.php
Once in the confirmation.php I am not able to grab the session values. I have tried the following:
<?php
session_start();
$_SESSION["subtotal"] = $_POST['SUBT'];
$_SESSION["tax"] = $_POST['TAX'];
echo $_SESSION["subtotal"];
echo $_SESSION["tax"];
echo $subtotal;
echo $tax;
?>
AND
$_SESSION["subtotal"] = $subtotal;
$_SESSION["tax"] = $tax;
echo $_SESSION["subtotal"];
echo $_SESSION["tax"];
echo $subtotal;
echo $tax;
?>
AND
$subtotal = $new_subtotal;
$tax = $new_tax;
echo $new_tax;
echo $new_subtotal;
?>
All have failed to see $_SESSION
- Is the value getting lost with the <iframe>
change?
I have used the following code on the products.php page to confirm the session were susecssfully created - They are:
echo $_SESSION["subtotal"]." stored in session <br />";
echo $_SESSION["tax"]." stored in session <br />";
NOTES:
- Both confirmation & products.php are on the same server.
- print_r($_SESSION); Returns BLANK array.
- session_start() is at the very top of both pages
confirmation.php
do this:-<?php session_start(); echo "<pre/>";print_r($_SESSION);
and check you havesubtotal
andtax
indexes in it or not? comment rest of the code for now – Anant Kumar Singhproduct.php
also? – Andre Polykanine