Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old October 12th, 2008, 01:15 PM
sheldonlg
Guest
 
Posts: n/a
Default 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
  #2  
Old October 12th, 2008, 07:55 PM
macca
Guest
 
Posts: n/a
Default Re: Tip about register globals set to "on"

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.

  #3  
Old October 13th, 2008, 12:35 AM
sheldonlg
Guest
 
Posts: n/a
Default Re: Tip about register globals set to "on"

macca wrote:
Quote:
What's the question?
Read the subject title! I am passing on a little personal experience,
and not asking a question.
Quote:
>
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.
Quote:
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.
Quote:
>
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles