RE: [PHP] Another Session Question..
| From: | Gonzalez, Zara E | Date: | Tue, 12 Mar 2002 21:47:28 +0000 |
| Subject: | RE: [PHP] Another Session Question.. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-88244@lists.php.net to get a copy of this message | ||
What I am trying to do is register a variable already in the request array...as
a session variable.
I know I can do $_SESSION['foo'] = $_REQUEST['foo'] but that's if I know
the
name of the variable that was registered on the form side.... I do know the
name, but it's dynamically generated.
So for example, the name could be foo1 - foo10 and I want to register all of
them as session variables.
So I want to be able to do this:
$count = 1;
$varname = "foo" . $count;
then do this:
$_SESSION[$varname] = $_REQUEST[$varname]
where the value of varname is actually the name of the variable that I want to
pull out....Does that make any sense?
I don't think that I can do $_SESSION['varname'] = $_REQUEST['varname'] in
this
case because I don't want the value of varname as a session variable....I want
the value of the value of varname as a session variable.
I'm not sure if I can do this...but I'd assume there has got to be some way, I
just don't know what it is.
Also, apparently the php manual warns not to use $_SESSION['var'] = $var with
session_register and session_unregister. So that wouldn't work for me anyway.
(http://www.php.net/manual/en/function.session-register.php)
Zara
-----Original Message-----
From: Coggeshall, John [mailto:john.coggeshall@delphiauto.com]
Sent: Tuesday, March 12, 2002 3:38 PM
To: Gonzalez, Zara E
Subject: RE: [PHP] Another Session Question..
If you are trying to register any variable... Say $foo...
Session_register('foo');
It will automatically appear in the $_SESSION array next time a page is
requested. I'm pretty sure it even will do it immediately (put it in
$_SESSION)
John
-----Original Message-----
From: Gonzalez, Zara E [mailto:gonzalze@mail.slh.wisc.edu]
Sent: Tuesday, March 12, 2002 4:23 PM
To: 'php-general@lists.php.net'
Subject: [PHP] Another Session Question..
I asked a question the other day about turning $_REQUEST variables into
$_SESSION variables...thanks, all who helped me with that...
I have another question about assigning $_REQUEST variables to $_SESSION
variables that I am hoping someone can help me out with....
Here is a snippit of code...
while($r = mssql_fetch_array($result)) {
$vname = $group_abbr . $count;
$_SESSION[$vname] = $_REQUEST[$vname];
}
Now an explanation...
$vname is the actual name of the variable that is stored in the
$_REQUEST array (and what I want it to be called in the $_SESSION array)
can I do this: ? (for example, a1 so $_SESSION['a1'] = $_REQUEST['a1'];
is what I want it to do...but I need to send the name of the variable as
a variable...)
I tried this...
$_SESSION[$vname] = $_REQUEST[$vname];
...but it doesn't seem to be working and I can't figure out how to get
those variables registered....
Any help is much appreciated.
Zara
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php