Jump to content


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


Session behaving strange

Recommended Posts

Hi all,

I've got a problem with $_SESSION[].

[i][b]Script entry[/b][/i]
1. Read values from a mysql result to session
foreach($sql_result as $name=>$value){
$_SESSION[$name] = $value;

2. [i]Debug[/i]: Display all values in $_SESSION
foreach($_SESSION as $name=>$value){
print($name . " = " . $value . "<br>");

3. Display nth wizard form (8 forms in total).
A wizard form is just a form containing part of the recordset I get from mysql in step 1.
If you put all the forms next to eachother you've got a graphical representation of the table's layout.

4. Save values on form submit
Whenever a wizard form submits ('next') I catch all the fields like this:
foreach($_REQUEST as $name=>$value){
$_SESSION[$name] = $value;

Since the field names correspond with the table field names the values posted will overwrite the ones that I read from the database.

5a. Display next wizard form -> step 2

5b. Write all values to mysql if no more wizard forms to display
[i][b]Script end[/b][/i]

This script worked for about 2 months but now suddenly acts really strange.

When I enable the debug part (display session contents & session adds) the following happens:

Wizard 1:
All variables are in $_session
Show valid periods -> select + next
Wizard 2:
$_SESSION['period'] = new value
Show valid age categorie -> select + next (or previous)
Wizard 3:
$_SESSION['age'] = new value
$_SESSION['period'] = [i][empty][/i]

I checked the following:
- I'm not making the '=' instead of '=='
- Other variables show the same beheavior, but only 3 out of 8
- The only time the script writes to the $_SESSION var's is by catching the $_REQUEST var's
- The rest of the script only reads from the var's eg: $query="SELECT .... WHERE period=".$_SESSION['period']

My system admin says it has got nothing to do with the server.
I can't recall that I made changes, other then sql query changes to this file since it was put in production.

Any ideas?

Share this post

Link to post
Share on other sites
Not really...

Stab in the dark seems as it appears you are using oop stuff - has the php engine been upgraded?

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.