亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

使用cookie實(shí)現(xiàn)統(tǒng)計(jì)訪問(wèn)者登陸次數(shù)

 更新時(shí)間:2013年06月08日 11:07:50   作者:  
本篇文章是對(duì)使用cookie實(shí)現(xiàn)統(tǒng)計(jì)訪問(wèn)者登陸次數(shù)的代碼進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
復(fù)制代碼 代碼如下:

<?php
$_COOKIE["counter"]?($c=$_COOKIE["counter"]+1):($c=1);
setCookie("counter",$c,time()+60);
echo "<b>歡迎您第"."<font color=#ff0000>".$c."</font>次訪問(wèn)cookie</b>";
?>

在這個(gè)應(yīng)用程序中,首先是瀏覽器請(qǐng)求一個(gè)資源(這個(gè)php頁(yè)面) ,發(fā)送下面的HTTP包頭內(nèi)容到服務(wù)器:
GET http://localhost/index.php HTTP/1.1
HOST:localhost
Accept:*/*
Accept-language:zh-cn
Accept-Encoding:gzip,deflate
User-Agent:Mozilla/4.0  (compatible;MSIE 6.0;Windows NT 5.1;SV1)
Connection:Keep-Alive

---------------------------------------------------------------------------
現(xiàn)在是動(dòng)態(tài)網(wǎng)頁(yè)程序(index.php)創(chuàng)建了Cookie,那么,服務(wù)器會(huì)傳輸下面的HTTP報(bào)頭內(nèi)容到瀏覽器:
HTTP/1.1   200   OK
Server:Apache/2.2.6 (Win32)  PHP/5.2.6
Date:Fri,23  Mar 2009 23:15:55 GMT
Connection:Keep-Alive
Content-Length:65
Content-Typt:text/html
Set-Cookie:VisitorCount=1; expires=Thr,30-Jul-2010 16:00:00 GMT;domain=localhost;path=/
Cache-control:private

GET http://localhost/index.php  HTTP/1.1
---------------------------------------------------------------------------

這將在客戶(hù)端保存一個(gè)cookie文件,并保存$c變量
當(dāng)再次請(qǐng)求時(shí),就會(huì)將cookie中的數(shù)據(jù)傳給服務(wù)器,例如下邊的HTTP請(qǐng)求報(bào)頭:

Accept:*/*
Accept-language:zh-cn
Pragma:no-cache
User-Agent:Mozilla/4.0(compatible;MSIE 6.0;Windows NT 5.1; SV1)
Host:localhost
Connection:Keep-Alive
Cookie:VisitorCount=1

相關(guān)文章

最新評(píng)論