Re: Creating Session Variables

From: Date: Thu, 03 Apr 2003 23:52:02 +0000
Subject: Re: Creating Session Variables
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-142219@lists.php.net to get a copy of this message
If you dont have register globals on, but find it convenient to access $varname instead of $_SESSION['varname'], you can extract($_SESSION), thought that has potential for other name conflicts and confusion, so be careful if you use extract(); "Tom Rawson" <trawson@clayst.com> wrote in message news:3E8C4978.25520.3F1D9E0F@localhost... > Hmmm, this doesn't seem clear in the docs ... > > Consider this: > > function foo() { > $_SESSION['varname'] = "test"; > ..... > } > > At this point: > > - Can I reference $varname inside the function? If so, must it be > declared global first? Or can I only reference it via > $_SESSION['varname']? > > - Can I reference it outside the function (as $varname) after the > function returns? > > In other words if one creates a variable by adding it to the session > array, does it then become a variable in either the global or (though I > can't quite imagine this) current local scope? > > Thanks, > > ---------- > Tom Rawson > > >

« previous php.general (#142219) next »