Results 1 to 3 of 3
  1. #1

    PHP sessions and includes

    Hi all!

    I'm trying to construct an order form. Basically, I've made all the different parts of the order form, numbered 1-30 and I've made one file, called order.php that includes the next file based on what the last post came from.

    That works all fine but I'm having trouble getting sessions to remember the data being posted. It will remember the post from one page to the next but not past that.

    The code consists of about 30 pages, so it's hard to post it here so I'll give a brief outline.

    order.php contains stuff like:

    if ($_POST[last_page] == '1') {
    } elseif ($_POST[last_page] == '2') {
    repeated about 30 times.
    I have the session_start etc in the right place, before any output, and I register each posted var as a session var but it doesn't seem to remember.

    Do sessions only work when you link from one page to the next, eg, 1.php posts to 2.php and so on, or can they work from one page, order.php which continually posts to itself and decides what to send to the browser based on the posted data.


  2. #2
    Join Date
    Dec 2002
    NY, NY
    make it like this..
                page 1
    value A
    value B
    value C
               page 2
    Value D
    Value E
    Value F
    Hidden value A = [A from other form (page 1)]
    Hidden value B = [B from other form (page 1)]
    Hidden value C = [C from other form (page 1)]
                    Page 3
    Value G
    Value H
    Hidden value A = [A from other form (page 2)]
    Hidden value B = [B from other form (page 2)]
    Hidden value C = [C from other form (page 2)]
    Hidden value D = [D from other form (page 2)]
    Hidden value E = [E from other form (page 2)]
    Hidden value f = [F from other form (page 2)]
    page 4
    receives all values..
    So basically..
    You need to have hidden fields in the forms.
    <input type="hidden" name="namehere" value="valuehere">
    and forward each value to the next page and then from their, follow everything to the next.

  3. #3
    or you could experiment.. as a debugger, at the top of each page or within the html output, do this:
    PHP Code:
    this dumps the entire contents of the SESSION array sent in the headers, if you see a value there but it isnt working in your page, you need to call it explicitly like this:
    PHP Code:

    if the $_SESSION dump does NOT show the data you need, then yes you need to include it next page with using a hidden form field or explicitly set the $_POST['value'] to a new variable, and assign that variable to the session registry.

    (also make sure sessions are being maintained on every page!)

    I make use of ADOdb's encrypted sessions stuff, storing "sid" in the database, so session id's wont need to be passed in the url (fugly stuff)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts