markspec87 Posted December 10, 2006 Share Posted December 10, 2006 2 of my variables will work but the third just doesnt want to work and im stumped why.index page code:[code]if (isset($_SESSION['username'])){ echo "Welcome back " . $_SESSION['username']; echo "click <a href='logout.php'>here</a> to logout<BR>"; echo "click <a href='editprofile.php?id=" .$_SESSION['userid']. "'>here</a> to edit your profile<BR>"; echo $_SESSION['userid']; }else{ echo "your not signed up, <a href='signup.php'>signup</a> now or <a href='login.php'>login!</a>";}[/code]the 4th echo for userid was just for debugging, but its still not working. The username works fine.Login code: (relevant)[code]if(mysql_num_rows($result) == 1){ // retrieve the access level $row = mysql_fetch_assoc($result); // set the session vars: $_SESSION['username'] = $_POST['username']; $_SESSION['accesslevel'] = $row['accesslevel']; $_SESSION['userid'] = $row['id'];}[/code]The row definitely exists and has values in the records, yet on the main page the variable is always null.Any ideas guys? Link to comment https://forums.phpfreaks.com/topic/30163-session-variables-id-doesnt-want-to-pass/ Share on other sites More sharing options...
trq Posted December 10, 2006 Share Posted December 10, 2006 I dont see any call to session_start(). Link to comment https://forums.phpfreaks.com/topic/30163-session-variables-id-doesnt-want-to-pass/#findComment-138636 Share on other sites More sharing options...
markspec87 Posted December 10, 2006 Author Share Posted December 10, 2006 yeh sorry ive missed bits out.Both files have session start, as i said, the username passes perfectly, but the ID just doesnt work. Link to comment https://forums.phpfreaks.com/topic/30163-session-variables-id-doesnt-want-to-pass/#findComment-138638 Share on other sites More sharing options...
trq Posted December 10, 2006 Share Posted December 10, 2006 well your setting $_SESSION['username'] to a $_POST variable while your others are being set from a row in the database. It would appear that row is not populated properly. Link to comment https://forums.phpfreaks.com/topic/30163-session-variables-id-doesnt-want-to-pass/#findComment-138640 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.