• [FRAMESET][PHP]Frameset下面使用php-header('location:...') redirect链接


    一般,我们的管理后台都是使用frameset来进行布局的,所以如果我们对后台的登录会话时间进行了设定,那么在超过该时间session失效之后,那么我们就必须要在php文件中进行判断处理。

    判断会话失效之后,那么就应该要执行跳转到登陆页面,让用户重新再次进行登录后台。

    如果我们直接使用php的header来实现跳转的话,那么代码就是:

    <?php
    
    if(......){// session is invalid
     
        $url = 'login.php';
        header('location:'.$url);
    }
    
    ?>

    在使用过程之中,我发现这样子跳转之后重新加载的login.php页面只会出现在id="mainframe"的frame中,看截图:

    后台页面布局如下:

    <frameset rows="70,*" cols="*" frameborder="no" border="0" framespacing="0">
    
      <frame src="index.php?action_type=top" name="topframe" scrolling="no" noresize="noresize" id="topframe" title="" />
    
      <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>
    <body>
    </body>
    </noframes>

    我应该去查一查php manual中关于header('location:...')的用法,http://hk2.php.net/manual/zh/function.header.php。

    后来我使用了stackoverflow别人给的代码来解决这个问题:

    <?php
    
    if($_SESSION['admin_id']==''){
    
      //header('Location:login.php');
      die("<script>
        if(typeof(parent) != 'undefined'){
            parent.window.location = 'login.php';
        }else{
            window.location.href = 'login.php';
        }
      </script>");
    }
    ?>
  • 相关阅读:
    vue中的$event
    vue实现div拖拽互换位置
    关于marquee首次加载出现闪跳问题
    微信小程序之深色模式下样式的写法
    html动态添加公共页头和页脚
    微信小程序改变上一页面的数据,页面中的通信
    mui中的a标签无效和click无法点击的问题
    mui.DtPicker is not a constructor解决方案
    mui-slider选项卡设置默认index
    flutter环境配置遇到的一些坑
  • 原文地址:https://www.cnblogs.com/shuman/p/3949858.html
Copyright © 2020-2023  润新知