help needed with Sessions and Regsiter_globals = on

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

help needed with Sessions and Regsiter_globals = on

Post 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
User avatar
Kriek
Forum Contributor
Posts: 238
Joined: Wed May 29, 2002 3:46 am
Location: Florida
Contact:

Post 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.
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Post 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
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Post 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
Post Reply