[FRAMESET][PHP]Frameset下面使用php-header('location:...') redirect链接
2014-09-01 19:04
302 查看
一般,我们的管理后台都是使用frameset来进行布局的,所以如果我们对后台的登录会话时间进行了设定,那么在超过该时间session失效之后,那么我们就必须要在php文件中进行判断处理。
判断会话失效之后,那么就应该要执行跳转到登陆页面,让用户重新再次进行登录后台。
如果我们直接使用php的header来实现跳转的话,那么代码就是:
在使用过程之中,我发现这样子跳转之后重新加载的login.php页面只会出现在id="mainframe"的frame中,看截图:
后台页面布局如下:
我应该去查一查php manual中关于header('location:...')的用法,http://hk2.php.net/manual/zh/function.header.php。
后来我使用了stackoverflow别人给的代码来解决这个问题:
判断会话失效之后,那么就应该要执行跳转到登陆页面,让用户重新再次进行登录后台。
如果我们直接使用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>"); } ?>
相关文章推荐
- header("Location:*****.php") 的使用
- PHP使用header+Location实现网站301重定向
- PHP使用header+Location实现网站301重定向
- 关于header('location:url')的一些说明,php缓冲区
- header('Location:'.C('VIP_HX').'/CmdId/'.$CmdId.'/user_id/'.$user_id.'/Token/'.$Token);
- 使用PHP程序header location 进行跳转的注意的一个细节!
- sql:逻辑文件名'A'已被使用,数据库名'A'已经被使用。
- php header()函数使用详解
- php的header和asp中的redirect比较
- PHP中如何使用header发送头部信息
- 使用js的alert后,使用location.href转向,不要使用redirect转向
- 【ZZ】一些在php中使用header函数设置http头的示例方法
- PHP Header使用注意事项
- PHP header() 详细使用说明与使用心得
- php header(location)容易被忽略小问题
- linux下面安装PHP时,提示:configure: error: Cannot find MySQL header files
- php中的header使用记录
- header(Location)标准的使用方法
- PHP中如何使用header发送头部信息
- 在php中使用mb_substr($row['title'],0,15,'utf-8')解决获取的字符后面几们的乱码问题