AdRock Posted March 11, 2008 Share Posted March 11, 2008 I have a really strange problem with sessions even tho the sessions are working When i login i get redirected to a success page (test page) which shows that the sessions are registering but when the success page loads, it appears that the page is ignoring the sessions when displaying links <div class="news"> <div class="heading"> <h3 class="head">Membership</h3> </div> <ul class="menu2"> <?php if(isset($_SESSION['username'])) { echo "<li><a href=\"edit_profile.php\">Edit Profile</a></li>"; echo "<li><a href=\"logout.php\">Logout</a></li>"; } else { echo "<li><a href=\"register.php\">Register</a></li>"; echo "<li><a href=\"login.php\">Login</a></li>"; } if ($_SESSION['user_level'] == 3) { echo "<li><a href=\"/admin/\">Admin Menu</a></li>"; } ?> </ul> </div> I want the links to change depending if the user has logged in or not. What is weird is that it will change later on but not straight away after the page redirects Link to comment https://forums.phpfreaks.com/topic/95694-strange-things-with-sessions-not-changing-links/ Share on other sites More sharing options...
soycharliente Posted March 11, 2008 Share Posted March 11, 2008 Do you have session_start() at the very top? You have to have session_start() in every page that uses sessions. Link to comment https://forums.phpfreaks.com/topic/95694-strange-things-with-sessions-not-changing-links/#findComment-489940 Share on other sites More sharing options...
AdRock Posted March 11, 2008 Author Share Posted March 11, 2008 I have a function called at the top of the page and in it is session_start It's really weird. When the page first redirects using header location, it doesn't change until i manually click a link, and when the page changes, the links change then Link to comment https://forums.phpfreaks.com/topic/95694-strange-things-with-sessions-not-changing-links/#findComment-489954 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.