473,326 Members | 2,133 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Tip about register globals set to "on"

I did some coding on a site where register_globals is set to on. The
problem I encountered was that the session variable changed without my
changing it explicitly. I knew that in register globals being on, that
all the variables were global variables. What I didn't realize was that
it set up an equivalence such that the variable is an alias for the
session variable with the key name of that variable. That is,
$_SESSION['key'] is the same as $key.

I got around the problem by changing the key of the the session variable
to something unique.

Here is a little test script:
<?php
session_start();
$_SESSION['company'] = 'This';
print '1: ' . $_SESSION['company'] . '<br>';
$company = 0;
print '2: ' . $_SESSION['company'] . '<br>';
$_SESSION['company'] = 'This';
print '3: ' . $_SESSION['company'] . '<br>';
$company = 'That';
print '4: ' . $_SESSION['company'];
$foo = 'Foo';
print '5: ' . $_SESSION['foo'] . '<br>';
?>

Here is the output:
1: This
2: 0
3: This
4: That
5: Foo
Oct 12 '08 #1
2 1700
What's the question?

I would recommend against using register_globals anyway. The directive
is deprecated and due for removal as of PHP 6 as it has security
vulnerabilities.

Oct 12 '08 #2
macca wrote:
What's the question?
Read the subject title! I am passing on a little personal experience,
and not asking a question.
>
I would recommend against using register_globals anyway. The directive
I agree totally, however it is not always under our control to make that
decision. Many places will not change because it would break too many
existing applications.
is deprecated and due for removal as of PHP 6 as it has security
vulnerabilities.
.....and that might hinder acceptance of PHP 6 if it will force turning
it off. That is for the reason I gave above.
>
Oct 12 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: Chris Krasnichuk | last post by:
hello, Does anyone know how I make php work on "my" computer? I made a mistake in my last post so I fixed it here. Chris
0
by: Justin | last post by:
Hi. I decided to tidy up some of my queries, but I came across something that stumpt me: mysql> SELECT -> jobs.jobId, -> jobs.active, -> jobs.title, -> jobs.listed, -> ...
0
by: Cave | last post by:
Is there a way to install the SQL Reporting Services Client on Whidbey ? The installer searches the system for an installation of Visual Studio 2003 in order to install the client part of SQL RPS....
0
by: Kevin Schneider | last post by:
Please forgive me if this is a bit off topic, but I haven't had any takers in other forums. With ASP.NET projects, is it possible to have VS.NET automatically change the configuration options of...
0
by: madmanpierre | last post by:
I have a Mobile Pocket PC app written in .NET, I notice that Explorer and other programs, when running, show up on the Start menu right below Start and right above Today in a list of icons on that...
2
by: John Smith | last post by:
I have more than 4,000 pieces of email in my Yahoo account. I would like to write a program to download them all. In order to write such a program, I need to know a few things. 1. After I fill...
7
by: Aaron G via AccessMonster.com | last post by:
Wanted to share a solution to something which I didn't find on the net: EVERY form in my Microsoft Access 2002 database gave an error any time any code was to be called: form OnOpen, button...
1
by: Todd | last post by:
I was wondering if someone has had a similar situation. We have a legacy VB6 application that is fairly large. We'd like to write new code in C# and have it launched from the VB6 application so it...
3
Curtis Rutland
by: Curtis Rutland | last post by:
OK, I have a question. I have a problem. I'm trying to catch all KeyDown events on a button, but the problem is when I press the "Enter" key, the button's "Click" event is triggered, not the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.