473,655 Members | 3,072 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

register_global s, effects on $_GET and $_SESSION

I read php manual many times but I can't figure out register_global s
works. I m using Php 4.3.2 and register_global s on. It seems to have
different effects on $_GET and $_SESSION. First with $_GET :

<? echo $var."\n";
echo $_GET['var']."\n";
$var="gna";
echo $var."\n";
echo $_GET['var']."\n";
$_GET['var']="gnou";
echo $var."\n";
echo $_GET['var']."\n";
?>

This page is called by <a href="work3.php ?var=gni">work3 </a>.
And produce this output :
gni
gni
gna
gni
gna
gnou
What I understand is that before reading the script, a global variable
is created with the same name and value as _GET['var'] but these are
eventually two distinct variables.

Then with $_SESSION :
<? session_start() ;
$_SESSION['test3'] = 'this is a test3';
?>
<a href="work5.php ">work5</a>

and in work5.php
<? session_start() ;
echo $test3."\n";
echo $_SESSION['test3']."\n";
$test3="gna";
echo $test3."\n";
echo $_SESSION['test3']."\n";
$_SESSION['test3']="gnou";
echo $test3."\n";
echo $_SESSION['test3']."\n";?>

This produce :
this is a test3
this is a test3
gna
gna
gnou
gnou
What I understand here is that before reading the script, a global
variable is created with the same name and value as _SESSION['test3']
but they share the same memory.

Where does it comes from ? Is it an extra work from session_start() ?

Jul 16 '05 #1
0 2589

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

Similar topics

4
12429
by: Frank | last post by:
Whats best : register_globals ON ? OR register_globals OFF ? I currently use: $_POST
1
1569
by: News | last post by:
All, I have some code that works just fine when register_globals is on, however, for obvious reasons, I am trying to rework the code so that I can disable register_globals. I have set my error_reporting to E_ALL, and am logging it to a file so that I can review it. Are there any "steps" to take in successfully updating the code ? Or do I just run each and every page looking for errors ?
2
3408
by: carramba | last post by:
Hi! Tahnx for taking time and reading! This script should load default page and default stylesheet, but its only loads default page, you have to actualy click on the style link to load style... but I dont understand why! It started when I "compresed" script and addet $_GET in the same "if" set... but it shoudent by eny problem...
8
2638
by: lian | last post by:
Hi all, I have installed a web-based software written in php which needs that i should turn "register_globals" from off to on in the php.ini. There are some comments for register_globals in php.ini saying: "You should do your best to write your scripts so that they do not require register_globals to be on; Using form variables as globals can easily lead to possible security problems, if the code is not very well thought of."
2
1934
by: Phil Latio | last post by:
I am newish to PHP and wish to create an authentication system where a new user is required to validate/complete their sign-up by clicking a link in an email. I am probably capable of putting something together where the user gets sent a link with a set of values but I am sure it would require "register_globals" set to ON. How is this achieved with "register_globals" set to OFF?
15
3384
by: news | last post by:
You'd think it'd be easier to find the answer to this question. Did a search, and all I can find is people asking why something's not working and people replying it's because register_globals is off. I found one person said: "The change is for the better since register_global turned to on had some grim security implications." but no mentioning of what those are! I'm working on a server now, with a couple hundred PHP pages someone has...
4
2950
by: Ham Pastrami | last post by:
My hosting provider has register_globals on. How big of a security risk is this, and is there a workaround for it if I can't convince them to turn it off? At the moment I am running phpbb and mantis on my site.
5
4917
by: Matthew | last post by:
Hi, !!I'm A Newbie Alert!! My server runs PHP version 4.4.3. I'm successfully creating a session and can set and retrieve my own session variables. As far as I can tell the $_SESSION variable should be created
10
25645
by: Kurda Yon | last post by:
Hi, I set the register_globals off and try to get my code working under the new conditions. I stuck on the following problem: Warning: Unknown(): Your script possibly relies on a session side- effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting...
0
8380
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8296
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8710
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8497
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8598
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2721
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1598
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.