session_register vs. $_SESSION superglobal
| From: | Kim L. Laage | Date: | Tue, 23 Mar 2004 14:54:21 +0000 |
| Subject: | session_register vs. $_SESSION superglobal | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-181273@lists.php.net to get a copy of this message | ||
Hi,
Newbie warning - this may be extremely simple.
I've been given a bit of code to get to work on our test machines, but at
the moment I'm drawing a blank. As far as I can tell the problem lies in the
dev. using a server environment with "register_globals = On", while we use
the default setting of "register_globals = Off".
The culprit in this seems to be this bit of code:
session_start();
session_register("user");
session_register("pass");
Which probably works with "register_globals = On", however I'd like to go
with the default and more safe setting of "register_globals = Off".
As far as I understand it I need to replace the two "session_register("*")"
lines with the superglobal $_SESSION, but I'm not sure of the syntax, at
first I tried this:
session_start();
$_SESSION = "user";
$_SESSION = "pass";
This doesn't work of course, but as I said I'm unsure of how the $_SESSION
superglobal is used, and the info I've found about it didn't shed much
light... I hope I'm just tired today 8-)
Another semi-related question is, is it common to include the username and
password for a site directly in the PHP code on a site... even if it is in
an include file?
--
/KLL