how to pass HTTP_SESSION_VARS to functions?
| From: | Andrew Elliston | Date: | Fri, 10 Nov 2000 17:37:47 +0000 |
| Subject: | how to pass HTTP_SESSION_VARS to functions? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-24673@lists.php.net to get a copy of this message | ||
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