Page 1 of 1

help needed with Sessions and Regsiter_globals = on

Posted: Wed Apr 23, 2003 4:16 pm
by Jade
Hey guys,

I've been working with sessions with register globals turned off and now i have to work with them turned on. Only problem is that they don't seem to be working as well for me now. I use them to keep track of different members for an online game. When a new member logins they get their own session and thats how i know who they are and what to display for their account, etc. Can any of you give me a crash course in sessions with register globals on that pertains to members where i have to have their name and password to get their information? I've tried going to the PHP manual lots of times but nothing seems to be working. I'd really appreciate it.

The way i've currently been doing it is:

Code: Select all

login.php

//they enter their login name and password

account.php

session_start();

define("SESSION_LENGTH", 60); 

$_SESSIONї"name"] = $_POSTї'login'];
$_SESSIONї"password"] = $_POSTї'password'];

$authname = $_SESSIONї"name"];
$authpass = $_SESSIONї"password"];

//then i use $authname and $authpass to pull their information from the database
However this doesn't seem to be working with globals on. Thanks for any help you can give.

Jade

Posted: Wed Apr 23, 2003 5:30 pm
by Kriek
The superglobal $_SESSION array is intended to be used when register_globals is turned OFF and apparently the session_register() function is intended to be used when register_globals is turned ON. Hope this helps. Though depending on your version of PHP you may just need to use $HTTP_SESSION_VARS instead.

Posted: Wed Apr 23, 2003 6:41 pm
by Jade
Okay, thanks

I will try it. I'm not sure if thats the problem though... I don't think my sessions are registering properly or something like that... any ideas there?
from the manual:

If you want your script to work regardless of register_globals, you need to use the $_SESSION array. All $_SESSION entries are automatically registered. If your script uses session_register(), it will not work in environments where register_globals is disabled.
food for thoughts....
Jade

Posted: Thu Apr 24, 2003 2:52 am
by twigletmac
Kriek wrote:The superglobal $_SESSION array is intended to be used when register_globals is turned OFF and apparently the session_register() function is intended to be used when register_globals is turned ON.
Not quite - you should be able to use $_SESSION whether reg_globals is on or off (that's the beauty of the autoglobals - same would apply to $_POST, $_GET et. al.) as per what the manual said. However, older versions (4.0.6 and below) may require session_register() to be used instead of $HTTP_SESSION_VARS.

What version of PHP are you using now?

Mac

Posted: Thu Apr 24, 2003 6:05 pm
by Jade
This is all the server info they have for me:

Cpanel Version/Build 6.4.0-STABLE Build 16
Operating System Linux
Apache Version 1.3.27 (Unix)
Perl Version 5.006001
Perl Path /usr/bin/perl
Installed Perl Modules Click to View
PHP Version 4.2.3
Mysql Version 4.0.12
Sendmail Path /usr/sbin/sendmail

If you want to see the phpinfo() for this site you can click here
http://www.whiteoakstables.net/test.php and see it.

I'm not sure why my sessions aren't being registered then....
Jade