Jump to content


This topic is now archived and is closed to further replies.


Problem managing sequence of session vars

Recommended Posts

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.

[code]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!

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.