Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8900455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:06:10+00:00 2026-06-15T01:06:10+00:00

I’m having issues maintaining variables in the Session. I’ve confirmed that the same Session

  • 0

I’m having issues maintaining variables in the Session. I’ve confirmed that the same Session ID persists through page navigation, and I’ve also used the Print_r($_SESSION) to monitor the variables.

I’m using four pages.

  • index.php
  • custinfo.php
  • custbilling.php
  • confirm.php

On the first page I’m using a form to send data to the next page.

        <form name="prescreen" action="custinfo.php" method="post">
        <label>From DIA</label>
        <input name="startlocation" id="fromdia" type="radio" value="From DIA">
        <label>To DIA</label>
        <input name="startlocation" id="todia" type="radio" value="To DIA">
        <label>Choose Location:</label>
        City:<input name="city" id="city" type="text" />
        <span>or</span><br />
        Zipcode:<input name="zipcode" id="zipcode" type="text" />
    <h3>When do you need picked up?</h3>
        <label>Choose Date:</label>
        <input name="date" id="date" type="datetime-local" />
        <label>Choose Time:</label>
        <input name="time" id="time" type="time" />
    <input type="submit"  value="Get a Ride Now!" class="textbtn"></input>
    </form>

On custinfo.php, I then use this in the head of the document:

 <?php
    session_start();

    $_SESSION['testvar'] = 'THIS IS A TEST';
    $startlocation = $_POST["startlocation"];
    $city = $_POST["city"];
    $zipcode = $_POST["zipcode"];
    $date = $_POST["date"];
    $time = $_POST["time"];

    //Assign variables to the Session
    $_SESSION['startlocation'] = $startlocation;
    $_SESSION['city'] = $city;
    $_SESSION['zipcode'] = $zipcode;
    $_SESSION['date'] = $date;
    $_SESSION['time'] = $time;

?>

The variables are properly read in and stored in the array. Then I use this form in the custinfo.php page:

        <form name="customerinfo" action="custbilling.php" method="post">
        <label>Contact Name</label>
        <input name="contactname" id="contactname" type="text">
        <label>Contact Email</label>
        <input name="contactemail" id="contactemail" type="text">
        <label>Contact Phone</label>
        <input name="contactphone" id="contactphone" type="text" />
        <?php
        if($_SESSION['startlocation'] == "From DIA")
        {
            echo '<hr />';
            echo '<label><b>To Location:</b></label>';
            echo 'Address1:<input name="toaddress1" id="toaddress1" type="text" />';
            echo 'Address2:<input name="toaddress2" id="toaddress2" type="text" />';
            echo 'City:<input name="tocity" id="tocity" type="text" />';
            echo 'Zip:<input name="tozip" id="tozip" type="text"  />';
            echo '<hr />';
        }
        else
        {
            echo '<hr />';
            echo '<label><b>From Location</b></label>';
            echo 'Address1:<input name="fromaddress1" id="fromaddress1" type="text" />';
            echo 'Address2:<input name="fromaddress2" id="fromaddress2" type="text" />';
            echo 'City:<input name="fromcity" id="fromcity" type="text" />';
            echo 'Zip:<input name="fromzip" id="fromzip" type="text" />';
            echo '<hr />';
        }

        ?>

        <input type="submit"  value="Book Your Ride!" class="textbtn"></input>
        </form>

In the head of the custbilling.php page I have everything pulling in like so:

<?php
session_start();

/*Vars from Customer Info */
$contactname = $_POST['contactname'];
$contactemail = $_POST['contactemail'];
$contactphone = $_POST['contactphone'];
if($_SESSION['startlocation'] == "To DIA")
{
    $address1 = $_POST['fromaddress1'];
    $address2 = $_POST['fromaddress2'];
    $city = $_POST['fromcity'];
    $zipcode = $_POST['fromzip'];
}
else
{
    $address1 = $_POST['toaddress1'];
    $address2 = $_POST['toaddress2'];
    $city = $_POST['tocity'];
    $zipcode =$_POST['tozip'];
}

//Assign Variables to the Session
$_SESSION['contactname'] = $contactname;
$_SESSION['contactemail'] = $contactemail;
$_SESSION['contactphone'] = $contactphone;
$_SESSION['address1']=$address1;
$_SESSION['address2']=$address2;
$_SESSION['city']= $city;
$_SESSION['zipcode'] = $zipcode;

?>

At this point, I’m displaying the information like so:\

<h1><?php echo $_SESSION['testvar']; ?></h1>
    <h2>Travel Information</h2>
    <h3>Please fill out this form:</h3>
    <p>Direction of Travel: <?php echo $_SESSION['startlocation']; ?></p>
    <p>LocationTo: <?php echo $_SESSION['city'] , $_SESSION['zipcode']; ?></p>
    <p>Date: <?php echo $_SESSION['date']; ?></p>
    <p>Time: <?php echo $_SESSION['time']; ?></p>
    <p>Customer Name: <?php echo $_SESSION['contactname']; ?></p>
    <p>Customer Email: <?php echo $_SESSION['contactemail']; ?></p>
    <p>Customer Phone: <?php echo $_SESSION['contactphone']; ?></p>
    <p>Address Information: <br />
        <span>Address 1:</span><?php echo $_SESSION['address1']; ?><br />
        <span>Address 2:</span><?php echo $_SESSION['address2']; ?><br />
        <span>City:</span><?php echo $_SESSION['city']; ?><br />
        <span>ZipCode:</span><?php echo $_SESSION['zipcode']; ?><br />
    </p>

But the startlocation and all the variables from the first post that were saved in the array are now erased. You can also see the testvariable that I used to test that the session was working, and my $_SESSION['testvar'] Displays properly on ALL of the files. I initially had the code set like so $_SESSION['varname] = $_POST['varname'];, but that produced the same issue. So the variable would go to the next page, but it wouldn’t continue to the third page.

Any help would be greatly appreciated. Thank you.

EDIT: This might be useful information:

Result from custinfo.php : bs2rrqoo5u1u5mjerkg54nkcb1 Array ( [startlocation] => From DIA [city] => Denver [zipcode] => [date] => 11/27/2012 [time] => 09:00 [fromaddress1] => [fromaddress2] => [fromcity] => [fromzip] => [toaddress1] => [toaddress2] => [tocity] => [tozip] => [contactname] => [contactemail] => [contactphone] => [address1] => [address2] => [testvar] => THIS IS A TEST [sameaddress] => 1 [billaddress1] => [billaddress2] => [billcity] => [billzip] => [ccnumber] => [ccexp] => [ccsc] => )

Result from custbilling.php : bs2rrqoo5u1u5mjerkg54nkcb1 Array ( [startlocation] => [city] => Aurora [zipcode] => 80017 [date] => [time] => [fromaddress1] => [fromaddress2] => [fromcity] => [fromzip] => [toaddress1] => [toaddress2] => [tocity] => [tozip] => [contactname] => Elijah Gartin [contactemail] => elijah.gartin@gmail.com [contactphone] => 3038804117 [address1] => 124 Test [address2] => [testvar] => THIS IS A TEST [sameaddress] => 1 [billaddress1] => [billaddress2] => [billcity] => [billzip] => [ccnumber] => [ccexp] => [ccsc] => )
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T01:06:11+00:00Added an answer on June 15, 2026 at 1:06 am

    The problem was on the server. I had to add session.save_path = "/var/location" to the php.ini file. Thanks for trying guys.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I used javascript for loading a picture on my website depending on which small
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
We're building an app, our first using Rails 3, and we're having to build

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.