PHP程序员站--PHP编程开发平台
 当前位置:主页 >> PHP基础 >> 基础文章 >> 

用php人工使网页过期

用php人工使网页过期

来源:互联网  作者:未知  发布时间:2008-01-21
Manually Expiring Web Pages 人工使网页过期 作者:

Manually Expiring Web Pages
  人工使网页过期

  作者: Joe Clark

  翻译: detrox

  After going through a series of pages during a registration process, you don't want the user to be able to go back after the final submit. What can you do to manually "expire" those pages, and perhaps display a custom message?

  在填写完成某注册过程中的一系列网页后,你不想用户能够在最终提交后回到以前的页面。你应该怎样做才能人工地使这些网页过期,并且如果有可能则给出一条已定制好的消息呢。

  In this scenario, I didn't want my session to expire as I needed it to continue. Instead, I used an extra session variable to track whether my session was alive or not. There are three main components: (1) the entry script, (2) the Cache-control directive, (3) the conditional check, and (4) manually expiring a portion of the session.

  在这一关里,我不想让我的session过期,因为我需要它能够继续运转。我使用一个额外的session变量来跟踪我的session是否为活动的。有三个主要的组件: (1) 入口脚本 (2) 缓存控制指示符 (3)条件检测 和 (4) 人工使一部分session过期。

  THE ENTRY SCRIPT

  入口脚本

  I use an entry script to start my session. This accomplishes two things: (1) destroys any session already in progress, and (2) starts a new session.

  我使用一个入口脚本来开始我的session. 它用来完成两件事: (1) 销毁任何已经存在于过程中的session,和(2) 开始一个新的session.

  entry.php:

  <?

  php  session_start();  session_unset();  session_destroy();  session_start();  session_register('alive');  $_SESSION["alive"] = "1";  Header("Location:/php/createaccount.php");?> 

  In the above script, we start the session, get rid of any registered session variables with session_unset(), and destroy that session with session_destroy(). Then, we start a new session and register a session variable. This particular variable will track whether this portion of the session is alive or not. We set the variable to some value, then we redirect to our first page in the registration series.

Tags: 网页   session   过期   php  
最新文章
推荐阅读
月点击排行榜
PHP程序员站 Copyright © 2007-2010,PHPERZ.COM All Rights Reserved 粤ICP备07503606号