• 页面刷新方式实时检测cookie是否失效


    在浏览器端每隔10秒钟刷新一次页面,可用于检查cookie值是否失效。

    在study.php文件中存在这样一条语句:

    <meta http-equiv="refresh" content="10;url=study.php">

    <?php
    session_start();
    if($_COOKIE['cookie1']!=''){	  
    ?>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <meta http-equiv="refresh" content="10;url=study.php">
    <title>使用COOKIE限制用户访问网站的时间</title>
    <style type="text/css">
    <!--
    .style1 {
    	font-size: 25px;
    	font-family: "华文行楷";
    }
    -->
    </style></head>
    
    <body>
    <table width="392" height="178" border="1" cellpadding="0" cellspacing="0" bgcolor="#FFFFCC">
      <tr>
        <td height="176" align="center">    
          <span class="style1">
        <p>用户您好</p></span>    <p>     您当前使用的是“试用版学习资源网”,主要应用COOKIE实现对网站访问时间的限制,当浏览者在网站中停留的时间超过网站规定的访问时间时,将自动跳转到登录页面,只有重新登录才可以继续访问 </p>      <p class="style1"> </p></td>
      </tr>
    </table>
    </body>
    </html>
    <?php
    }else{ 
    	echo "您在本网站停留的时间已经超过我们限制的时间,系统将在5秒钟后退出登录!!谢谢!请稍等...";
    	echo "<meta http-equiv="Refresh" content="5;url=index.php">";
    }
    ?>
    

      

    它的作用是,每隔10秒刷新一次当前页面。作用是:后续逻辑会检测cookie是否过期,只有通过不断刷新,才能完成对cookie的实时检测

  • 相关阅读:
    shell脚本比较字符串相等
    从自身的经历讨论手工测试与自动化测试
    读《Linux Shell脚本攻略》(第2版) 一遍、二遍体会
    也许开发需要的只是一份简单明了的表格
    linux 命令:tr 的简单使用
    docker的数据持久化
    docker基础操作
    centos7 docker镜像源设置
    DockerUI(图形化管理)
    Docker 常用命令
  • 原文地址:https://www.cnblogs.com/ioveNature/p/6918286.html
Copyright © 2020-2023  润新知