Solved

php session variables auto load

Posted on 2009-05-12
3
335 Views
Last Modified: 2012-05-06
Hi to all,
I have a problem. If session has a variable it create a php variable when i start session?

For example i call my code test.php?test=blabla
after this call session has testMe variable.
after this when i call just test.php there is $testMe php variable?

i think it is a php setting. how can i disable this settign?
Ps: php runs on linux
<?php
session_start();
if (isset($_GET["test"])){
	$_SESSION["testMe"]="Test string...";
	$testMe=$_SESSION["testMe"];
}
echo var_dump($_SESSION);
echo var_dump($testMe)
?>

Open in new window

0
Comment
Question by:erenpasa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 39

Accepted Solution

by:
Roger Baklund earned 500 total points
ID: 24363233
0
 
LVL 11

Expert Comment

by:VanHackman
ID: 25699437

If you set some session variable you can access it using the associative array  "$_SESSION". This session variable is a 'superglobal', or automatic global, variable. This means that it is available in all scopes throughout a script.  So  looks like the variable is "autoloaded" like a php local variable in the script.

To fix this issue, you have two options:

1 - Turn off the "Register Globals" directive editing the php.ini file
2 - Turn off the "Register Globals" with the .htaccess entry: php_flag register_globals off
3 - Use different names for the sessions variables and local variables.

more finfo:

     http://php.net/manual/en/ini.core.php#ini.register-globals

Bye!    
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question