Session Variable Resetting
I have a php file called process.php that sets a session variable, namely $_SESSION['transtype']. This page also contains a form that is submitted to final.php.
If I echo the value of $_SESSION['transtype'] at the end of the process.php file, it displays the correct value. However, in final.php, it is no longer set.
In final.php I have the following snippet of code. The output of this page is "Not set." Why is the value of 'transtype' being lost between these 2 pages?
$itemID = $_POST['item'];
$numItems = $_POST['numItems'];
echo "Not set.";
What does the code look like in your login page? The relevant part, anyway.
Here is the code from process.php where transtype gets set correctly:
<form method='post' action='final.php' name='order' onSubmit='return validateForm();'>
$orderID = $_POST['orderID'];
$_SESSION['orderID'] = $orderID;
$_SESSION['transtype'] = "insert";
$_SESSION['transtype'] = "update";
$_SESSION['transtype'] = "delete";
Do you need to see more?
The session_start() function should throw an error, because you have output data to the browser before starting the session. Try putting session_start() at the beginning of the document, before you put any HTML code.
Thanks so much for your help. That took care of it. I never would have figured that out on my own.
Happy to help.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)