0
   

Regarding Register_Globals in PHP

 
 
Reply Mon 11 Jan, 2010 11:29 pm
Hi there,
I think that these [register_globals] is set ON to support the use of Super Global Variables like($_SESSION,$_POST etc.,)

am I right?

But in my localhost server,
Even though by default register_globals is turned OFF,i can able to use super global variables ($_SESSION,$_POST like that..) in my code...

can u anybody suggest me regarding this doubt...

Thanks in advance

By
Ars
  • Topic Stats
  • Top Replies
  • Link to this Topic
Type: Discussion • Score: 0 • Views: 1,421 • Replies: 2
No top replies

 
Robert Gentel
 
  2  
Reply Mon 11 Jan, 2010 11:48 pm
@Aravindh,
Aravindh wrote:
Hi there,
I think that these [register_globals] is set ON to support the use of Super Global Variables like($_SESSION,$_POST etc.,)

am I right?


Not really. register_globals made any variable, no matter how it was input available from $variablename. So if it's on I can pass in any variable value I want as a query string value. For example I could circumvent the following code just by passing in ?authorized=1 to the script:

Code:<?php
// define $authorized = true only if user is authenticated
if (authenticated_user()) {
$authorized = true;
}

// Because we didn't first initialize $authorized as false, this might be
// defined through register_globals, like from GET auth.php?authorized=1
// So, anyone can be seen as authenticated!
if ($authorized) {
include "/highly/sensitive/data.php";
}
?>


For that kind of reason this is a highly-discouraged practice and has been removed from the latest version of PHP altogether, so avoid reliance on this kind of thing. In practice that means doing stuff like $_GET['myvariable'] instead of just using $myvariable.

Quote:
But in my localhost server,
Even though by default register_globals is turned OFF,i can able to use super global variables ($_SESSION,$_POST like that..) in my code...


Superglobals are pre-defined variables and turning register globals on and off only affects them in the way they can be accessed. For example, with register globals on, you can access the the variable like this: $DOCUMENT_ROOT but with it off you access it through one of the pre-defined super global arrays like this: $_SERVER['DOCUMENT_ROOT'].
Aravindh
 
  1  
Reply Tue 12 Jan, 2010 10:24 pm
@Robert Gentel,
Right..Thanks Robert..I got clear..
0 Replies
 
 

Related Topics

Webdevelopment and hosting - Question by harisit2005
Showing an Ico File - Discussion by Brandon9000
how to earn money in internet - Discussion by rizwanaraj
The version 10 bug. Worse then Y2K! - Discussion by Nick Ashley
CSS Border style colors - Question by meesa
There is no Wisdom in Crowds - Discussion by ebrown p
THANK YOU CRAVEN AND NICK!!! - Discussion by dagmaraka
I'm the developer - Discussion by Nick Ashley
 
  1. Forums
  2. » Regarding Register_Globals in PHP
Copyright © 2024 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.03 seconds on 04/26/2024 at 02:27:14