ok. i'm well aware of the perils of register_globals ON. i set my local dev server to register_globals OFF and on all of the live sites i run i set it OFF via custom php.ini.
the problem is if you are writting a PHP app for distribution that will run on a wide variety of PHP installs then you need your code to run properly with register_globals ON or OFF. most code that is register_globals OFF compliant should run fine in a register_globals ON environment. however there is one small bug/feature involving sessions and register_globals ON.
do this test script with register_globals ON:
<?php
session_start();
$_SESSION['var'] = 'test1';
$var = 'test2';
echo $_SESSION['var'];
?>
when the page is refreshed the above script outputs "test2" even though the session var was only set to "test1". the problem is that any session variables that share the same name as global variables will change values with the global variable (as if always passing by reference). i have known about this bug for a while but i always been able to work around it via turning OFF register_globals. but again, if you are designing an app to run on all servers what is the best solution to this? register_globals cannot be turned OFF at runtime via ini_set(). i am also aware of the session.bug_compat_42 directive but this does not make any difference.
can we simply not use the same variable names in sessions and in the global scope? that's seems pretty impractical. is there something obvious that i am missing that would effectively mitigate this problem?
any thoughts?