UTAlan Posted March 21, 2007 Share Posted March 21, 2007 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!!! Link to comment https://forums.phpfreaks.com/topic/43664-solved-values-of-session-vars-changing-unexpectedly/ Share on other sites More sharing options...
kenrbnsn Posted March 21, 2007 Share Posted March 21, 2007 Do you have register_globals enabled? This will happen when they are enabled. Ken Link to comment https://forums.phpfreaks.com/topic/43664-solved-values-of-session-vars-changing-unexpectedly/#findComment-211963 Share on other sites More sharing options...
Orio Posted March 21, 2007 Share Posted March 21, 2007 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. Link to comment https://forums.phpfreaks.com/topic/43664-solved-values-of-session-vars-changing-unexpectedly/#findComment-211964 Share on other sites More sharing options...
UTAlan Posted March 21, 2007 Author Share Posted March 21, 2007 That was the problem. Thank you for your help! Link to comment https://forums.phpfreaks.com/topic/43664-solved-values-of-session-vars-changing-unexpectedly/#findComment-211970 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.