Re: session vars set in functions invalid??

From: Date: Tue, 19 Dec 2000 23:08:09 +0000
Subject: Re: session vars set in functions invalid??
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-31075@lists.php.net to get a copy of this message
Michael, I'm pretty new to PHP, but I've learned that functions have their own scope - to use any variables in a function that got their values outside the function, you must declare them "global" in the function. HTH. -- Hardy Merrill Mission Critical Linux, Inc. http://www.missioncriticallinux.com Michael Geary [michael.geary@seranova.com] wrote: > Hi all, > > I am trying, as I'm sure many others are, to come up with a compact user > authentication/login scheme. > > It seems to me that for my purposes, the best way to go is to run a function > which receives the username and supplied password. A lookup in my database > is performed, and a session variable is set which tells me who the user is. > > My database lookup works just fine. However, It appears that session > variable scope doesn't penetrate outside of functions. Can this be? I > thought the whole point of session variables was that they are accessible > from anywhere. If I can't set a session variable within a function, then it > appears that I have to in-line code the authentication process wherever it > is needed, which seems rather silly to me. > > Unless I can get some clarity on this, it seems I will have to roll my own > session handling using a temporary database table. Can anyone give me some > help to spare me from this work? > > Thanks in advance, > > michael geary > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#31075) next »