Re: session vars set in functions invalid??

From: Date: Tue, 19 Dec 2000 23:35:48 +0000
Subject: Re: session vars set in functions invalid??
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-31093@lists.php.net to get a copy of this message
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 >

« previous php.general (#31093) next »