05-11-2005, 01:43 AM | #1 (permalink) |
Addict
|
PHP converting $_SESSION to $HTTP_SESSION_VARS
I had some scripts which used $_SESSION to register variables to a session, each page had session_start() at the top of the script and everything worked fine, however I now need to change them for php 4.0.6 and simply replacing $_SESSION with $HTTP_SESSION_VARS is not working
why???? |
05-11-2005, 03:35 PM | #2 (permalink) |
Once upon a time...
|
could it be a register_globals issue?
http://ie.php.net/session_register
__________________
-- Man Alone ======= Abstainer: a weak person who yields to the temptation of denying himself a pleasure. Ambrose Bierce, The Devil's Dictionary. |
06-01-2005, 06:48 AM | #3 (permalink) |
Junkie
|
$HTTP_SESSION_VARS is not an auto-global, if I remember correctly. That means it is outside the scope of any function or method in your script. You could use register_globals, but that assumes your sysadmin will allow you to set PHP directives. If you can't do that, try putting this line in every function or method that refers to the session variables:
Code:
function my_func() { global $HTTP_SESSION_VARS; echo $HTTP_SESSION_VARS['some_var']; } |
06-01-2005, 09:36 AM | #4 (permalink) | ||||
Addict
|
Yeah.
$HTTP_SESSION_VARS is deprecated and should only be used on old versions of php. (pre 4.06) So it seems you're going back in time here... That and many others were changed when PHP grew up a little. There were bad security holes and they changed the globals to correct it. I had a similar problem with legacy code a few months back. http://www.tfproject.org/tfp/showthr...&highlight=php Quote:
Here's what I ended up having to do. Using $_GET, instead of some basic variables. ($preset was just another variable that was used to pull stuff from the URL - queries were passed in the url.) Compare this: (PHPv5) PHP Code:
PHP Code:
http://us4.php.net/manual/en/functio...n-register.php Quote:
Quote:
Quote:
And finally, a page where someone actually writes a walkthrough of the same issue: http://www.phpbuilder.com/tips/item....6&print_mode=1 |
||||
Tags |
$httpsessionvars, $session, converting, php |
|
|