Re: session_register in function

From: Date: Sun, 25 Feb 2001 07:01:33 +0000
Subject: Re: session_register in function
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-41552@lists.php.net to get a copy of this message
I had this same exact problem just today. It all stems from the variable namespace, I think.... A similar code 'snippet' is shown below. I just made it up, but I think it illustrates my point. <?php session_start (); function crud ($user, $password) { session_register ('user'); session_register ('password'); $GLOBALS['user'] = $user; global $password; /* NOTE: $GLOBALS['varname'] = $value is the same as global $varname. Either will work....*/ } echo "User is $user and password is $password"; ?> Good luck with whatever you are doing, Jeff Lacy ""Jon Rosenberg"" <php@columbusinteractive.com> wrote in message news:000901c09e7d$16835420$0100a8c0@slinkyboi5... > The variable I register before the function becomes available in the session > to other pages...the variable I register inside the function are not > accessible in the session to ohter pages. Is this normal? How can I work > around this? Thanks! PHP4.0.4pl1 on Linux. > > sample code: > > <? > session_Start(); > > $foo = "bar"; > session_register("foo"); > > function bob($user){ > $username = $user . "one"; > $username2 = $user . "two"; > session_register("username"); > session_register("username2"); > return true; > } > ?> > > > -- > 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 (#41552) next »