Solved

php session variables auto load

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now