Jump to content

Session behaving strange


unicatcher

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
[code]
foreach($sql_result as $name=>$value){
$_SESSION[$name] = $value;
}
[/code]

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

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:
[code]
foreach($_REQUEST as $name=>$value){
$_SESSION[$name] = $value;

}
[/code]
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]

[b]Problem[/b]
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?
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.