Ted
Ted

Reputation: 3875

Firefox session development issue

My website under development has a weird issue.
once logged in, the user is redirected to read the license agreement. In this page called terms.php I conditionaly show a confirm button that redirects the user to a page called agreed.php if the user is logged in, and else: to register.php.

The weird thing is only in Firefox (has firebug installed).
once logged in, the terms.php's form is showing action="register.php" ! instead of agreed.php, and all checks I made show that the user is NOT logged in. Another weird thing, is if I hit F5 to refresh, It shows agreed.php! It doesn't happen in IE nor in Chrome.

Any idea what this might be ?

function logged_in() {
    return isset($_SESSION['USER_ID']);
}

function redirect_to( $location = NULL) {
    if ($location != NULL) {
        header("Location: {$location}");
        exit;
    }
}

login.php

if (shouldReadTerms())
    redirect_to("terms.php");

terms.php

    <?php if(logged_in()): ?> 
    <?php if (shouldReadTerms()): ?>
        <form action="agreed.php" method="POST">
    <?php endif; ?>
    <br />
    <br />
    <button <?php if (!shouldReadTerms()) echo 'disabled'; ?>>I Agree </button>
    <?php if (shouldReadTerms()): ?>
        </form>
    <?php endif; ?>
    <br />
    <br />
<?php else: ?>
    <form action="register.php" method="POST">
    <br />
    <br />
    <button>I Agree</button>
    </form>
<?php endif; ?>

Upvotes: 0

Views: 1011

Answers (3)

Ted
Ted

Reputation: 3875

Sad but true: changed:

redirect_to("terms.php");

to

redirect_to("terms.php?".rand());

Problem solved. Although not 100% sure of why. But it works like a charm for now

Upvotes: 0

ShaaD
ShaaD

Reputation: 626

This bug can be two reasons. Session and cache.

If you are confident that the problem only in FF for the start delete cookies and clear the browser cache.

If this does not help add to terms.php

header("Cache-Control: no-cache, must-revalidate");

If this also does not help try to see a dump of the session at each step after authorization.

Upvotes: 2

David Barker
David Barker

Reputation: 14620

If it isn't an issue in IE or Chrome you could try

<meta http-equiv="cache-control" content="no-cache">

in the header on that page.

Upvotes: 1

Related Questions