1

So This part of my code:

print_r($_SESSION['T']);
$T = array_values($data2);
print_r($_SESSION['T']);

Outputs this:

Array ( [0] => NZL ) Array ( [0] => ENG [1] => NZL ) 

That line is the first time $T is declared. As far as I can tell there should be NO reason for $_SESSION['T'] to gain an entry and its definitely causing me problems.
Might be good to note that after that array_values call, the var $T looks like:

Array ( [0] => ENG [1] => NZL ) 

Which is what the second print of $_SESSION['T'] is displaying.

Let me know if you can think of any reason this might be happening, thanks

Josh K
  • 562
  • 1
  • 4
  • 11
  • I think this is the good ole "session side effect" bug. Hang on, I'll see whether I can find the reference. – Pekka May 14 '10 at 19:24

3 Answers3

4

Looks like you might have Register Globals turned on.

if (ini_get('register_globals')) {
    die("Register Globals is ON - This is BAD");
}
else  {
    die("Register Globals is OFF - This is GOOD");
}

The idea was that - with register globals - you could use a variable $T as a shorthand for $_GLOBALS['T']... or $_GET['T'] or $_POST['T'] or (of course) $_SESSION['T'].

If it sounds like a bad idea, that's because it is (was) and has now been so aggressively discouraged that it is deprecated and usually off by default.

Richard JP Le Guen
  • 28,364
  • 7
  • 89
  • 119
1

This is a known bug/side-effect. See this question for details. It should be sortable by setting register_globals to off.

Community
  • 1
  • 1
Pekka
  • 442,112
  • 142
  • 972
  • 1,088
1

This is probably caused because you have register_globals set to on (Which is absolutely terrible). (See http://www.php.net/manual/en/security.globals.php)

You should disable register globals so that the SESSION/POST/GET/REQUEST/COOKIE variables do not interfere.

Mitch Dempsey
  • 38,725
  • 6
  • 68
  • 74