Firefox会话开发问题

时间:2012-05-17 10:02:30

标签: php html firefox

我正在开发的网站有一个奇怪的问题 登录后,用户将被重定向以阅读许可协议。在名为terms.php的此页面中,我有条件地显示确认按钮,如果用户已登录,则会将用户重定向到名为agreed.php的页面,否则:register.php

奇怪的是只有Firefox(安装了firebug) 登录后,terms.php的表单会显示action="register.php"!而不是agreed.php,我做的所有检查都表明用户没有登录。 另一个奇怪的事情是,如果我按F5刷新,它会显示agreed.php! 它不会发生在IE或Chrome中。

知道这可能是什么吗?

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; ?>

3 个答案:

答案 0 :(得分:2)

这个bug可能有两个原因。会话和缓存。

如果您确信只在FF中启动问题,请删除cookie并清除浏览器缓存。

如果这无助于添加terms.php

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

如果这也无助于在授权后尝试在每一步看到会话转储。

答案 1 :(得分:1)

如果在IE或Chrome中不是问题,您可以尝试

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

在该页面的标题中。

答案 2 :(得分:0)

伤心但真实: 改变:

redirect_to("terms.php");

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

问题解决了。 虽然不是100%肯定为什么。但它现在就像一个魅力