Hi, Wednesday, July 23, 2003, 6:22:58 AM, you wrote: JS> I have a function that assigns some session variables I need available JS> during a user's visit. Oddly enough, as I assign about 7 variables, I JS> noticed that not all had data. This is the function:
JS> function setupUserEnv ($userArray) { JS> $_SESSION['loggedIn'] = 1; JS> $_SESSION['id'] = $userArray['id']; JS> $_SESSION['uid'] = $userArray['uid']; JS> $_SESSION['fname'] = $userArray['fname']; JS> $_SESSION['lname'] = $userArray['lname']; JS> $_SESSION['dateapproved'] = $userArray['dateapproved']; JS> $_SESSION['email'] = $userArray['email']; JS> } JS> Pretty straight forward. I've used var_dump as soon as I enter the function JS> to make sure $userArray is populated the way I expect - it always is. Only JS> the session variables for 'loggedIn', 'uid' and 'dateapproved' stay set JS> outside of this function. However, I can set a session var not used in my JS> program in this function, and it'll stick: $_SESSION['justTesting'] = JS> "test"; will stay set outside of this function. JS> If I put a var_dump at the end of the function for $_SESSION, I see all JS> session vars are set within the scope of the function. Once outside of the JS> function, some stay set, some do not. JS> I've read the chapter in the manual about variable scope, and it seems JS> pretty clear that $_SESSION is a superglobal, and I do not have to declare JS> it with the 'global' keyword. JS> I've tested this on three separate installations of PHP/Apache, and I get JS> the same behavior each time. JS> Anyone clue me in to what I'm doing wrong? Thanks! JS> -- JS> Jeff Stillwall Try passing a reference to the array like this function setupUserEnv (&$userArray) { $_SESSION['loggedIn'] = 1; $_SESSION['id'] = $userArray['id']; $_SESSION['uid'] = $userArray['uid']; $_SESSION['fname'] = $userArray['fname']; $_SESSION['lname'] = $userArray['lname']; $_SESSION['dateapproved'] = $userArray['dateapproved']; $_SESSION['email'] = $userArray['email']; } Otherwise no idea at this point :) -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php