* Thus wrote Jeff Stillwall ([EMAIL PROTECTED]):
> I have a function that assigns some session variables I need available
> during a user's visit.  Oddly enough, as I assign about 7 variables, I
> noticed that not all had data.  This is the function:
> 
> 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'];
> }
> 
> Pretty straight forward.  I've used var_dump as soon as I enter the function
> to make sure $userArray is populated the way I expect - it always is.  Only
> the session variables for 'loggedIn', 'uid' and 'dateapproved' stay set
> outside of this function.  However, I can set a session var not used in my
> program in this function, and it'll stick: $_SESSION['justTesting'] =
> "test"; will stay set outside of this function.
> 
> If I put a var_dump at the end of the function for $_SESSION, I see all
> session vars are set within the scope of the function.  Once outside of the
> function, some stay set, some do not.
> 
> I've read the chapter in the manual about variable scope, and it seems
> pretty clear that $_SESSION is a superglobal, and I do not have to declare
> it with the 'global' keyword.

So i would also assume you have called session_start() already. and yes
global for version >= 4.1.0

> 
> I've tested this on three separate installations of PHP/Apache, and I get
> the same behavior each time.
> 
> Anyone clue me in to what I'm doing wrong?  Thanks!

<quote>
If register_globals is disabled, only members of the global associative
array $_SESSION can be registered as session variables. The restored
session variables will only be available in the array $_SESSION. 
</quote>

I can't make heads or tails what that means.

I've set up something what you describe, it works for me:

http://zirzow.dyndns.org/php/session.php


Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to