一般,我们的管理后台都是使用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>");
}
?>

[FRAMESET][PHP]Frameset下面使用php-header('location:...') redirect链接的更多相关文章

  1. header("location:test.php")跳转成功需要注意的

    header("location:test.php")跳转成功除了需要注意以下三点还有一个前提必须要注意: 1.location和":"号间不能有空格,否则会出 ...

  2. 关于header('location:url')的一些说明,php缓冲区

    网上搜索header('location:url')的用法,得到如下三个结论: 1. location和“:”号间不能有空格,否则会出错. 2. 在用header前不能有任何的输出. 3. heade ...

  3. header("Location:login.php")

    header("Location:login.php")应该注意的几个问题  header("Location:")作为php的转向语句.其实在使用中,他有几点 ...

  4. session_id() , session_start(), $_SESSION["userId"], header("Location:homeLogin.php"); exit 如果没有登录, 就回登录页

    if(!session_id()) session_start(); header("Content-type:text/html;charset=utf-8"); if (emp ...

  5. HTTP header location 重定向 URL

    http头信息 头信息的作用很多,最主要的有下面几个:1.跳转当浏览器接受到头信息中的 Location: xxxx 后,就会自动跳转到 xxxx 指向的URL地址,这点有点类似用 js 写跳转.但是 ...

  6. header("Location:http://www.baidu.com");

    php 中的跳转函数 header("Location:http://www.baidu.com"); 但是一定要放在文件的开头   不允许有任何输出. 否则在之前添加  ob_s ...

  7. PHP使用header+Location实现网站301重定向

    对于我们SEO人员来说,有的时候需要对网站进行重定向.一般来说,对网站重定向的http返回状态码是301和302两种.下面兰州SEO就通过实例来为你介绍一下怎样通过PHP使用header+Locati ...

  8. 【frameset】frameset设置不能拖动

    <frameset rows='20%,*' >           <!--  row 行 col 列    分行列要为rows  cols  --> <frame s ...

  9. header('Location:'.C('VIP_HX').'/CmdId/'.$CmdId.'/user_id/'.$user_id.'/Token/'.$Token);

    利用header函数做跳转,跳转至C('VIP_HX')配置文件中VIP_HX的地址下,携带参数CmdId 值为 $CmdIduser_id 值为 $user_idToken 值为 $Token th ...

随机推荐

  1. SMO算法(转)

    作者:[已重置]链接:https://www.zhihu.com/question/40546280/answer/88539689来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请 ...

  2. blat

    1)  产生背景---------------------------------------------------2002年的时候,随着人类基因组项目不断推进,需要将大量ESTs(300万) 及m ...

  3. Android中MD5加密

    最近项目中遇到MD5加密,代码很简单,又是死代码,不过要注意当长度不足32的时候要补个0.下面是具体代码,直接拷贝就能用. public static String getMD5(String str ...

  4. 操作符重载operator

    发现一篇好文: 转载: http://www.cnblogs.com/xiehongfeng100/p/4040858.html #include <iostream>#include & ...

  5. 【校招面试 之 C/C++】第25题 C++ 智能指针(一)之 auto_ptr

    1.智能指针背后的设计思想 我们先来看一个简单的例子: void remodel(std::string & str) { std::string * ps = new std::string ...

  6. 粘性Service

    粘性Service就是一种服务 把他删去他又会马上创建 原理是在这个服务中去开启线程不断检测此服务是否存在如果不存在,咋就会重新创建 import android.app.Activity; impo ...

  7. BroadcastReceiver接收电量变化的广播-------在代码中动态创建接受者

    本例为动态创建广播接收者即不是在AndroidManifest.xml文件中定义的广播接收着 代码: package com.qf.broadcastreceiver01; import androi ...

  8. VBA json parser[z]

    http://www.ediy.co.nz/vbjson-json-parser-library-in-vb6-xidc55680.html VB-JSON: A Visual Basic 6 (VB ...

  9. qt基本类

    多firstpage secondpage thirdpage fouthpage  实现 多页面 xml解析 实现 按钮 和 slot实现 mysql数据库访问实现

  10. 测试用例Excel模板For Quality Center

    Subject Test Name Description Step Name  Step Description Expected Result PU Regr\Component\Attribut ...