zaffryn Posted September 9, 2013 Share Posted September 9, 2013 Good day, I am having a weird issue with my sessions first of all I have different pages like so: index.php (login screen) checklogin.php login_success.php My login_success.php page works fine it will gather the information from the database and display it. On that page I have 2 links 1 is Update and the other one is Upload Pic. When I go to update.php it is returning me all the right information in my input boxes. but If i select the Upload Pic link i have no more session variable. Upload.php that is loaded when upload Pic is clicked (echo $_SESSION['pusername']; will not even return anything) <? session_start(); if(!isset($_SESSION['pusername']) ){ echo "not set"; } echo $_SESSION['pusername']; ?> <html> <body> <form action="upload_file.php" method="post" enctype="multipart/form-data"> <label for="file">Filename:</label> <input type="file" name="file" id="file"><br> <input type="submit" name="submit" value="Submit"> </form> </body> </html> the update.php page when i click the link. this one works perfectly <? session_start(); if(!isset($_SESSION['pusername']) ){ echo "not set"; } ob_start(); $host = ""; $username = ""; $password = ""; $db_name = ""; $tbl_name = ""; mysql_connect("$host","$username","$password") or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select db"); $puser = $_SESSION['pusername']; $sql = "UPDATE $tbl_name SET Pub_companyName = '$_POST[myusername]',Pub_companyEmail = '$_POST[myemail]', Pub_companyWebsite = '$_POST[mywebsite]' WHERE Pub_User = '$puser'"; $result=mysql_query($sql) or die(mysql_error()); $result = mysql_query($sql); if(!$result){ die("Error running $sql:" . mysql_error()); } header("location:/test/functions/login_success.php"); echo " 1 item added "; ?> Link to comment https://forums.phpfreaks.com/topic/281998-weird-session-issues/ Share on other sites More sharing options...
mac_gyver Posted September 9, 2013 Share Posted September 9, 2013 you didn't state if you are getting the echo "not set"; output? depending on that output, the troubleshooting is different - if you are getting the 'not set' message, it means your session id likely didn't match (most likely because the host-name/sub-doman in the url's changed.) if you are not getting the 'not set' message and nothing is displayed from the echo $_SESSION['pusername']; statement, it likely means that your code is accidentally overwriting the session variable. Link to comment https://forums.phpfreaks.com/topic/281998-weird-session-issues/#findComment-1448859 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.