register_globals, effects on $_GET and $_SESSION

This is a discussion on register_globals, effects on $_GET and $_SESSION within the PHP Language forums, part of the PHP Programming Forums category; I read php manual many times but I can't figure out register_globals works. I m using Php 4.3....


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-21-2003
Thomas Carcaud
 
Posts: n/a
Default register_globals, effects on $_GET and $_SESSION

I read php manual many times but I can't figure out register_globals
works. I m using Php 4.3.2 and register_globals 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() ?

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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




All times are GMT +1. The time now is 04:12 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0