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!
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.
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.
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.
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.
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.
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