Returning values from functions
| From: | Jason Giangrande | Date: | Wed, 09 Jul 2003 22:39:50 +0000 |
| Subject: | Returning values from functions | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-154647@lists.php.net to get a copy of this message | ||
I have a function that checks to see if a user has an active session and
if so I'd like it to return the value of a variable (the variable
$username). However, when I var_dump the variable it's value is NULL.
Anyone know why? Here's the function:
function auth_user($logged_in) {
if (isset($logged_in)) {
list($s_username, $hash) = explode(',',$logged_in);
global $secret_word;
if (md5($s_username.$secret_word) == $hash) {
$username = $s_username;
return $username;
} else {
die ("You have tampered with your session.");
}
} else {
die ("Sorry, you are not logged in. Please log in and try again.");
}
}
Here's the code that calls the function which is in another script.
auth_user($_SESSION['login']);
var_dump($username);
Thanks,
Jason Giangrande