RE: [PHP] session vars set in functions invalid??

From: Date: Wed, 20 Dec 2000 01:24:33 +0000
Subject: RE: [PHP] session vars set in functions invalid??
Groups: php.general 
Request: Send a blank email to php-general+get-31115@lists.php.net to get a copy of this message
Thanks Richard & Hardy for the insights. I now have my scheme working via the global function. However, it still seems very strange to me that session variables would be affected by scope. Can anyone comment on the intent/value of this? -michael > ---------- > From: Richard Lynch > Sent: Tuesday, December 19, 2000 4:35 PM > To: php-general@lists.php.net > Subject: Re: [PHP] session vars set in functions invalid?? > > function session_login($username, $password){ > global $session_id; > . > . > . > } > > Or, have the function *return* the session_id. > > Or, provide a pair of functions to read/write the ID, which really just > alters a global variable. > > Or... > > ----- Original Message ----- > From: Michael Geary <michael.geary@seranova.com> > Newsgroups: php.general > Sent: Tuesday, December 19, 2000 4:45 PM > Subject: [PHP] session vars set in functions invalid?? > > > > 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 > > > > > -- > 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 (#31115) next »