为什么这个 js-php 生成的位置引用在 IE8 中不起作用


Why does this js-php generated location reference does not work in IE8?

为什么这个js-php生成的位置引用在IE8中不起作用?

<script>
<?php
    session_start();
        $_SESSION['admintermorol']=false;
        echo "window.location='".$_SERVER['HTTP_REFERER']."';";
?>
</script>

我不确定,但你可以用纯 php 来做到这一点,替换

echo "window.location='".$_SERVER['HTTP_REFERER']."';"; 

exit(header("Location: {$_SERVER['HTTP_REFERER']}'r'n"));

不起,这有点不对劲

将代码移动到页面顶部(而不是在脚本标记内)

<?php
session_start();
if ( !isset($_SESSION['admintermorol']))
{
    exit(header("Location: {$_SERVER['HTTP_REFERER']}'r'n"));
}
?>

或者(现在我知道)你可以这样做:-)

<?php
session_start();
$_SESSION['admintermorol'] = FALSE;
exit(header("Location: {$_SERVER['HTTP_REFERER']}'r'n"));
?>