You are here: Re: How to call the session variable? « PHP Programming Language « IT news, forums, messages
Re: How to call the session variable?

Posted by Michael Fesser on 01/14/08 13:28

..oO(Peter Pei)

>What an idiot! He tested and they are related - that's a fact. How many
>times I told you in other threads the same thing?

How many times you were told that you're wrong? $_SESSION['foo'] and
$foo are only related if register_globals is turned on. A simple test:

<?php
session_start();

if (isset($_GET['show'])) {
print '<pre>';
print_r($_SESSION);
var_dump($foo);
var_dump($bar);
print '</pre>';
} else {
$_SESSION['foo'] = 23;
$_SESSION['bar'] = 42;
}
print "<a href='{$_SERVER['PHP_SELF']}?show'>next</a>";
?>

After calling the script and clicking the link, the result with
register_globals = ON will be:

Array
(
[foo] => 23
[bar] => 42
)
int(23)
int(42)

This is what the OP got. Now the same thing with register_globals = OFF:

Array
(
[foo] => 23
[bar] => 42
)

Notice: Undefined variable: foo in ...
NULL

Notice: Undefined variable: bar in ...
NULL

This is how it should be on a properly configured system.

Micha

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация