Re: how to pass HTTP_SESSION_VARS to functions?

From: Date: Fri, 10 Nov 2000 18:10:32 +0000
Subject: Re: how to pass HTTP_SESSION_VARS to functions?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-24683@lists.php.net to get a copy of this message
On Fri, 10 Nov 2000, Andrew Elliston wrote: > I'm having a "little" trouble understanding how to pass session variables to > functions. > I can get the session variables to pass between pages by accessing them with HTTP_SESSION_VARS > (which also protects them from being replaced by new values in URL), but not between functions. I > can get the session variables to pass between functions if I don't use the HTTP_SESSION_VARS > method, but then the variables are susceptible to being overwritten from the URL. > > How would I do this? > > What I have is like what's below - but I get a PHP error or no value, no matter what > combination I seem to try. > > test.php contains the following: > > <? > session_start(); > require ("common.inc"); > > session_register("variable"); > $HTTP_SESSION_VARS["variable"] = "test"; > > if (check_variable ($HTTP_SESSION_VARS["variable"])) echo "yes, $variable == > test"; > ?> > > common.inc contains the following: > > <? > function check_session ($HTTP_SESSION_VARS["variable"]) { > if ($variable=="test") return (TRUE); > } > ?> > > Thanks, > Andrew Elliston > Try: <? ... if (check_variable ($HTTP_SESSION_VARS["variable"])) echo "yes, $variable == test"; ?> <? function check_session ($var) { return ($var==="test") } ?> The actual array doesn't mean anything to the function. It's not a matter of passing the array at all. -- Ignacio Vazquez-Abrams <ignacio@openservices.net>

« previous php.general (#24683) next »