用PHP人工使網頁過期
上一篇 / 下一篇 2007-12-31 01:06:43 / 個人分類:php
- 文件版本: V1.0
- 開發商: 網絡來源
- 文件來源: 網絡
- 界面語言: 繁中
- 授權方式: 免費
- 運行平台: Win9X/Win2000/WinXP
用PHP人工使網頁過期 detrox [翻譯]
{/_$f0{o#e7d[0關鍵字 網頁過期,註冊網頁編寫頂客社區_,U"Wj*I9KT
出處 http://www.phpbuilder.net/columns/clark20030702.php3頂客社區*KC/S3w0Z*o!A`y'x]
頂客社區-H%s-n)io)Wt
Manually Expiring Web Pages頂客社區0n7qg;qK
F't
人工使網頁過期頂客社區 B7f^&J|EC4ZI
作者: Joe Clark頂客社區|[1wN8R W
翻譯: detrox頂客社區?&LQ.{[8L
8q
bUu jdP$a0After 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?頂客社區 y;iF?Z!O K1RfhI,[
在填寫完成某註冊過程中的一系列網頁後,你不想用戶能夠在最終提交後回到以前的頁面。你應該怎樣做才能人工地使這些網頁過期,並且如果有可能則給出一條已定制好的消息呢。頂客社區j4{%Rk(oM
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.
U z&rp`g^h9@0在這一關裏,我不想讓我的session過期,因為我需要它能夠繼續運轉。我使用一個額外的session變數來跟蹤我的session是否為活動的。有三個主要的組件: (1)入口腳本(2)緩存控制指示符(3)條件檢測和(4)人工使一部分session過期。頂客社區1axL ])w1A$`j2X Iu
THE ENTRY SCRIPT
M/yk6\h"K
t0入口腳本頂客社區-`-x7a_Z
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.
$o1r)CB%no5I?H0entry.php:
I9wh;mPo0<?頂客社區)Bt`pn+?-{
php session_start(); session_unset(); session_destroy(); session_start(); session_register('alive'); $_SESSION["alive"] = "1"; Header("Location:/php/createaccount.php");?> 頂客社區ck[:A_,V
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.頂客社區Y%i@#T*?Hd
在上面的腳本中,我們開始session,用session_unset()清除一切已經註冊的session變數,並且用session_destory()來銷毀先前的session。然後,我們開始一個新的session並且註冊一個session變數。這個特定的變數將跟蹤表示這部分session是否為活動的。我們將為變數設置一些值,之後重定向到我們的一系列註冊網頁的第一頁。頂客社區Q:UmF0f
CACHE-CONTROL AND CONDITIONAL CHECK
n-~ L3l,]2Q0緩存控制和條件檢測
M
v9}8N&Yb0In the following code snippet, we will auto-detect if the session is still in use.
&O