Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    Regular Coder
    Join Date
    Aug 2010
    Thanked 2 Times in 2 Posts

    push to session variable overwrites

    I know, know, know I'm probably doing something wrong here, but one thing at a time.

    On a form submission that sends only one _POST item, I reload the page, and I want to push that "_POST" data into a Sessions variable.
    and have something like: Array ( [Category1] => information1 )

    Then when they make a choice on the page, the second time, I want the process to repeat, and add the variable to get:

    Array ( [Category1] => information1, [Category2] => information2 )

    Doing it this way, it works, but it overwrites the variable, instead of just adding to it. On the second reload, I just get:
    Array ( [Category2] => information2 )

    CORRECTION: I get an empty array. nothing's going into the SESSIOn variable

    My challenge is that I don't know what the _POST name/key will be, because it's generated by a database query, and a loop. At least at my experience level, I don't know of a way to get that information.

    This is the Session bit, I'm trying unsucessfully to use:

    PHP Code:

    $_SESSION['options_picked'] = array();

    if (isset(
    $_POST)) {
    // I don't know how to get: $_POST['unknown-variable'];

    $testtitt $_POST;


    $_SESSION['names'][] = $testtitt;
    // I also tried array_push. Same result.

    print_r($_SESSION['options_picked']); // for testing result.
    Last edited by turpentyne; 08-01-2012 at 12:45 AM.


Posting Permissions

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