Jump to content

[SOLVED] Values of Session Vars Changing Unexpectedly


UTAlan

Recommended Posts

I am having issues with sessions. When a user logs in, I set some session vars and cookies:

 

session_start();

$email = $_POST['email'];
$_SESSION['email'] = $email;
$_SESSION['name'] = mysql_result($getUser, $index, 'fName');
$time = mysql_result($getUser, $index, 'time');
setcookie("userID", $userID, time() + 2592000, "/");
setcookie("sID", md5($time . $sID . $time), time() + 2592000, "/");

 

 

I have a page that allows admin to view and update the contact information of users on the site. I use a select box that reloads the page and populates a form with the selected user's information. Here's the code that is called when the page is reloaded:

 

$myAgentID = $_POST['agentID'];
$getAgent = mysql_query("SELECT * FROM tbl_agents WHERE agentID = '$myAgentID'");
echo $_SESSION['email'] . "<br />";
$email = mysql_result($getAgent, 0, 'email');
echo $_SESSION['email'] . "<br />";

 

As you can see, I am not doing anything to change the value of my session variables in this code. However, this is what is echoed:

 

[email protected]
[email protected]

 

If I change "$email" to any other name (e.g. $myEmail), it fixes the problem in this instance. But I'm having issues with it elsewhere as well...I just don't understand why the value to my session variable is changing when I'm using a local variable.

 

 

Any ideas? Let me know if you need more information. Thanks!!!

 

I think this is a register_globals issue.

 

To check if register globals is set, run this script and check the output:

<?php echo ini_get("register_globals"); ?>

 

If it is set, it's very recommended to turn it off (you can do that by editing you php.ini). Also, it will solve your problem.

 

Orio.

 

EDIT- ken beat me to it.

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.