简体   繁体   中英

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.

The code is simple.

PHP Code:

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.

Here is my layout of frameset code. HTML Code:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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