plznty Posted November 16, 2010 Share Posted November 16, 2010 // SESSION TEST if ($_SESSION['username']) { require_once("../mysql.php"); // Find Username from Session ID // Find Username from ID $finduser="SELECT username FROM users WHERE id='$_SESSION[username];'"; $finduserquery=mysql_query($finduser)or die(mysql_error()); $userfetch = mysql_fetch_array($finduserquery); // Set Username Variable $userfromid = $userfetch['username']; echo "lol" . ucwords($userfromid); } else { } Everytime I load this page more than once when logged in, it seems to turn the variable blank. Therefore making the user not be able to view other pages that use a session. Help? Thanks Link to comment https://forums.phpfreaks.com/topic/218833-_session-changing/ Share on other sites More sharing options...
revraz Posted November 16, 2010 Share Posted November 16, 2010 Where is session_start? Why dont you set a session variable saying they are logged in and then don't query the database again if so? Link to comment https://forums.phpfreaks.com/topic/218833-_session-changing/#findComment-1134928 Share on other sites More sharing options...
plznty Posted November 16, 2010 Author Share Posted November 16, 2010 I have done, the login section works but if I visit this page something in what I have just shown changes the session['username'] variable. Link to comment https://forums.phpfreaks.com/topic/218833-_session-changing/#findComment-1134930 Share on other sites More sharing options...
revraz Posted November 16, 2010 Share Posted November 16, 2010 Nothing in the code you pasted changes the session variable. Link to comment https://forums.phpfreaks.com/topic/218833-_session-changing/#findComment-1134949 Share on other sites More sharing options...
plznty Posted November 16, 2010 Author Share Posted November 16, 2010 I cannot understand why its changing then. Confusing. Link to comment https://forums.phpfreaks.com/topic/218833-_session-changing/#findComment-1135123 Share on other sites More sharing options...
plznty Posted November 16, 2010 Author Share Posted November 16, 2010 It apparently is okay without register_globals being on, but how can i do this without. Link to comment https://forums.phpfreaks.com/topic/218833-_session-changing/#findComment-1135144 Share on other sites More sharing options...
Pikachu2000 Posted November 16, 2010 Share Posted November 16, 2010 Why is register_globals on to begin with? Link to comment https://forums.phpfreaks.com/topic/218833-_session-changing/#findComment-1135148 Share on other sites More sharing options...
plznty Posted November 16, 2010 Author Share Posted November 16, 2010 Why is register_globals on to begin with? My web host provider has it on, what site do you get hosting off? I want to change, they have on outdated things such as magic quotes. Link to comment https://forums.phpfreaks.com/topic/218833-_session-changing/#findComment-1135154 Share on other sites More sharing options...
Pikachu2000 Posted November 16, 2010 Share Posted November 16, 2010 You can't use your own php.ini file with them? If you can, you can disable those things for your site. Link to comment https://forums.phpfreaks.com/topic/218833-_session-changing/#findComment-1135155 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.