Jump to content


Session behaving strange

  • Please log in to reply
2 replies to this topic

#1 unicatcher

  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 28 July 2006 - 01:21 PM

Hi all,

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

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

2. Debug: 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
Script end

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'] = [empty]

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?

#2 ToonMariner

  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 28 July 2006 - 02:23 PM

Not really...

Stab in the dark seems as it appears you are using oop stuff - has the php engine been upgraded?
follow me on twitter @PHPsycho

#3 Ninjakreborn

  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 28 July 2006 - 02:25 PM

what php version do you have.


Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users