【问题标题】:PHP use header location to redirect in the framesetPHP 使用标头位置在框架集中重定向
【发布时间】:2014-08-30 04:42:08
【问题描述】:

会话无效后,我使用php中的标头位置重定向到登录页面。

代码很简单。

PHP 代码:

if($_SESSION['admin_id']){

  header('location:login.php');
}

但是问题发生了,当超时时,我刷新浏览器在我的布局的主框架中加载 login.php。

这是我的框架集代码布局。 HTML 代码:

>>><frameset rows="135,*" cols="*" frameborder="no" border="0" framespacing="0">

  <frame src="index.php?action_type=top" name="topframe" scrolling="no" noresize="noresize" id="topframe" title="" />
  <!--<fram src ="index.php?action_type=content" name="maiframe" scrolling="no" noresize="noresize" id="mainframe" />-->

  <frameset cols="225,*" frameborder="no" border="0" framespacing="0">

    <frame src="index.php?action_type=menu" name="menuframe" scrolling="no" noresize="noresize" id="menuframe" title="" />

    <frame class="framebordertop" src="index.php?action_type=login-info" name="mainframe" scrolling="auto" noresize="noresize" id="mainframe" title="" />

  </frameset>

</frameset>

<noframes>

</noframes>

【问题讨论】:

    标签: php html frameset


    【解决方案1】:
    <?php
    
    if( ....... ){ //if session is invalid
        die("<script>
            if(typeof(parent) != 'undefined'){
                parent.window.location.href='login.php';
            }else{
                window.location.href='login.php';
            }
        </script>");
    }
    
    ?>
    

    试试这个?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-01
      • 2022-01-17
      • 2012-08-03
      • 2019-05-22
      • 1970-01-01
      • 2016-11-06
      • 2011-04-01
      相关资源
      最近更新 更多