Re: Legal $_SESSION names

From: Date: Sat, 23 May 2009 14:27:15 +0000
Subject: Re: Legal $_SESSION names
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-293023@lists.php.net to get a copy of this message
At 2:25 PM +0100 5/23/09, Stuart wrote:
2009/5/22 tedd <tedd@sperling.com>: Regardless of what anyone may say to the contrary, it doesn't work
everywhere. I found that out the hard way. The fix is simply to use a different name for the variable, such as: $my_var = $_SESSION['myvar'];
I'm just guessing but I'd say this has to do with the way superglobals are created. Since 5.0.0 a configuration option called auto_globals_jit has existed and it defaults to being on. It causes the creation of superglobals to be delayed until they are actually used. I don't know how it interacts with register_globals (the manual says it'll be disabled if register_globals is on) but it makes sense to me that this issue is related to that. I'd say you've found a bug, but you'll need a repeatable example before you can report it. -Stuart
-Stuart: I'm pretty sure it's a bug -- all of my scripts work and one doesn't within the same environment. I have a routine where an Administrator can bypass the logon procedures of a registered user to the site and see what the user sees. To do that I simply use a bypass session variable namely: $bypass = $_SESSION['bypass']; I use this exact same statement in 13 different scripts and it works. However, in one script, I have to change the statement to: $by_pass = $_SESSION['bypass']; to make it work. Otherwise it fails with some vague error code about using something that has been depreciated. Considering that the error is surrounded by so much code, I don't want to wade through it all and find the exact problem and report it. Instead, I'm just saying if someone runs into this problem like this, they might try changing the variable name. It's a simple fix, but it's hard to identify. Cheers, tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.com

« previous php.general (#293023) next »