Jump to content


Photo

Problem managing sequence of session vars


  • Please log in to reply
No replies to this topic

#1 phpdino

phpdino
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 04 April 2006 - 10:00 PM

I have made a script for a survey. There are 8 themes to choose from. For each theme I then have 8 subthemes. Each set of subthemes is stored in a separate include file.

In screen 1 the user has to chose his / her 3 preferred themes from 8. In screen 2 I include the subthemes file that goes with the first chosen theme. Screen 3: subthemes for second chosen theme. Screen 4: subthemes for third chosen theme.

I use session vars to store the choices while the user evolves through the survey (he can also use the back button for example to change a previous answer). Only in the end I write the data to a static file. And this is where the problem lies.

If I check the contents of the session array (print_r) all data are there and they are in the correct order. But if I write the data to the static file (txt) then I always have some vars missing. I can’t find a logic in it. One time it’s this var and then it’s another.

foreach ($_SESSION as $var) {
            $line .= $var . ";";
            }

I would think that going through the sequence of screens should provide me each time with the same order of vars in the session array. But this is not the case. The order gets mixed up, vars are missing (when writing to the file!). In all I have some 93 vars in the session array. Question: does anyone have experience with this? Would 93 be too much? Or how to make sure that the writing of the file succeeds?

I have tried to write the file without the foreach loop, by just concatenating all the vars into one general $line to write. But that doesn’t succeed either. At var 47 or so the parser reports an error (about an ] error which is not the case in fact).

To write the data to a database is not an option.

Thanx for any help!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users