Jump to content

[SOLVED] PHP is loosing variables


MadnessRed

Recommended Posts

I seem to be loosing variables.

 

Here is my code

 

echo "[".$_SESSION['user']."]<br />";
$user = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `Login` = '".$_SESSION['user']."' AND LIMIT 1 ;"));
echo "[".$_SESSION['user']."]<br />";

 

and here is the output.

Why does php loose the value of $_SESSION['user'] when I try and use it?

 

[Anthony]
[]

Link to comment
https://forums.phpfreaks.com/topic/164773-solved-php-is-loosing-variables/
Share on other sites

Possibly something to do with your PHP version. I have seen before that you can use variables like $user to grab the value of $_REQUEST['user'] automatically. Try this:

 

echo "[".$_SESSION['user']."]<br />";
$query = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `Login` = '".$_SESSION['user']."' AND LIMIT 1 ;"));
echo "[".$_SESSION['user']."]<br />";

Because register_globals are on. Turn them off as quick as possible. They were turned off by default in php4.2 in the year 2002, but a lot of people did not get the message on how dangerous they are.

 

$user, $_POST['user'], $_GET['user'], $_COOKIE['user'], and $_SESSION['user'] are all cross populated when register_globals are on.

Because register_globals are on. Turn them off as quick as possible. They were turned off by default in php4.2 in the year 2002, but a lot of people did not get the message on how dangerous they are.

 

$user, $_POST['user'], $_GET['user'], $_COOKIE['user'], and $_SESSION['user'] are all cross populated when register_globals are on.

 

ok many thanks, is it possible to turn them off without access to php.ini

If you're running PHP as an Apache module you can add this to a .htaccess file:

php_flag register_globals Off

 

Then send an email to your host requesting that they hire competent sysadmins.

 

ok many thanks

ps, its not my host, im helping out someone else on their server.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.