简体   繁体   English

PHP使用标头位置在框架集中重定向

[英]PHP use header location to redirect in the frameset

I use header location in php to redirect to login page after the session is invalid. 会话无效后,我使用php中的标头位置重定向到登录页面。

The code is simple. 代码很简单。

PHP Code: PHP代码:

if($_SESSION['admin_id']){

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

But the problem happen, while times out , i refresh browser the login.php load in the main frame of my layout. 但是问题发生了,尽管超时了,但我在布局的主框架中刷新了浏览器的login.php负载。

Here is my layout of frameset code. 这是框架集代码的布局。 HTML Code: 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

if( ....... ){ //if session is invalid
    die("<script>
        if(typeof(parent) != 'undefined'){
            parent.window.location.href='login.php';
        }else{
            window.location.href='login.php';
        }
    </script>");
}

?>

Try this ? 尝试这个 ?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM