Jump to content

Strange things with sessions not changing links


AdRock

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.