Page 1 of 1

Sessions and register globals

Posted: Sun Mar 02, 2003 2:06 pm
by Jade
[Admin Edit: moved from the sessions sticky thread]

Quick Question.

I know sessions work different with register_globals on and off. I'm not quite sure i understand how they work differently. I run an internet game of my own server and i leave register_globals off. However, I also develop internet games for other people where they can just install them on their servers. I'm hhaving trouble writing a login script using sessions where it doesn't matter if register globals is on or off. Any suggestions?

Posted: Sun Mar 02, 2003 2:27 pm
by Stoker
It shouldn't matter if you explicit use $_SESSION for all session data, as Jason posted above..

Edit/Add: If you NEVER user $blah and ALWAYS use $_SESSION['blah'] when setting and reading session data, there is no way register_globals makes a difference, if so it would be a bug in PHP i believe...

Posted: Sun Mar 02, 2003 3:52 pm
by Jade
Actually, I think there is a difference.

In my game, if i turn register_globals on and you log in as PHP you are taken to the account that is actually for the member ASP...etc. Its like the sessions aren't corresponding to the right member, even though i start a new one for EVERY member. There has to be a difference if this is only happening to me with register_globals on.

Jade

Posted: Mon Mar 03, 2003 2:22 am
by twigletmac
Unless you are switching PHP versions then there is no reason why sessions would not work as expected with reg_globals on or off - $_SESSION exists either way so something else might be affecting the code.

Mac

Posted: Mon Mar 03, 2003 2:33 pm
by Jade
Well, then I have no clue why my sessions won't work with register globals on. I have over 1k members on my site and when i tried installing a chat that required register_globals to be on my members were logging in and then their sessions were screwing up. If you have any clues why, let me know. It would help lots.

Jade

Posted: Tue Mar 04, 2003 3:14 am
by twigletmac
If you are using $_SESSION and add some code that uses session_register() then sessions will be messed up, the superglobals and the old session functions do not play nicely together.

Maybe that could be part of your problem although without seeing the code it's difficult to diagnose.

Mac

Posted: Tue Mar 04, 2003 2:29 pm
by Jade
My sessions:

session_start();

define("SESSION_LENGTH", 60);

$_SESSION["name"] = $_POST['loginname'];
$_SESSION["password"] = $_POST['password'];

$membername = $_SESSION["name"];
$memberpass = $_SESSION["password"];


that's how i'm doing it.

Jade

Posted: Tue Mar 04, 2003 2:31 pm
by twigletmac
There's nothing in the chat script that uses sessions?

Mac

Posted: Tue Mar 04, 2003 2:33 pm
by Jade
nope, nothing. Weird huh? Maybe it does have to do with the sessions....dunno

Jade