Solved

php session variables auto load

Posted on 2009-05-12
3
333 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Why isn't my DIV and Form centering? 1 28
php hashing methods 3 49
Form not executing correctly 1 28
SSL on Apache 2... config file 1 31
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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.

734 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