bouwob Posted May 18, 2007 Share Posted May 18, 2007 ok I have this at the top of every page if (!isset($_SESSION['user'])) { session_start(); $_SESSION['user'] = "4"; $_SESSION['browse'] = "4"; echo "ho"; } if (isset($_SESSION['user'])) { echo "hi"; $userid = $_SESSION['user']; } else $userid = ""; if (isset($_SESSION['browse'])) $browseid = $_SESSION['browse']; else $browseid = ""; echo $_SESSION['browse']."----".$_SESSION['user']; when I get to any page I get a printout of "hohi4----4 " and then I have a login page with this code if ($_POST["user"] != "UserName" && $_POST["password"] != "Password") { $query = "select username, userid from users where username = '".$_POST["user"]."' and password = '".$_POST["password"]."'"; $result = querydatabase ($query); while($row = mysql_fetch_assoc($result)) { $username = $row['username']; $userid = $row['userid']; } echo ($username == $_POST["user"]).$userid; if ($username == $_POST["user"]) { $_SESSION = array(); session_destroy(); session_start(); $_SESSION['browse'] = "5"; $_SESSION['user'] = $userid; $whatToDo = "display uname"; } } when I go to that page and login I get a print out of this "11hi5----1" ok everything up untill this point is working as intended. the problem is that when I then click a home link I get "hohi4----4 " when it should say "hi5----1". Are sessions directory sensitive? The home page does not have any other session code other than the 1st section of code I posted. The sessions are dieing when going from the login page to the home page. any ideas? if you go to http://www.nolanryancardmuseum.com/login/index.php you can play around with it. just hit submit to login tia Quote Link to comment https://forums.phpfreaks.com/topic/51929-php-sessions-not-acting-as-intended/ Share on other sites More sharing options...
Gobbo Posted May 18, 2007 Share Posted May 18, 2007 <?php if (!isset($_SESSION['user'])) {... ?> 'session_start();' should be placed before this. Quote Link to comment https://forums.phpfreaks.com/topic/51929-php-sessions-not-acting-as-intended/#findComment-256039 Share on other sites More sharing options...
bouwob Posted May 18, 2007 Author Share Posted May 18, 2007 thank you so much. I have been trying to figure that out for so long. cheers Quote Link to comment https://forums.phpfreaks.com/topic/51929-php-sessions-not-acting-as-intended/#findComment-256059 Share on other sites More sharing options...
pocobueno1388 Posted May 18, 2007 Share Posted May 18, 2007 Don't forget to mark the topic as "solved" so people don't get confused =] Quote Link to comment https://forums.phpfreaks.com/topic/51929-php-sessions-not-acting-as-intended/#findComment-256063 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.