Copy CodeThe code is as follows:
$_cookie["Counter"]? ($c =$_cookie["Counter"]+1):($c =1);
Setcookie ("Counter", $c, Time () +60);
echo "
Welcome to the section ".". $c. " Second Access Cookie";
?>
In this application, the browser is the first to request a resource (this PHP page), send the following HTTP header content to the server:
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
---------------------------------------------------------------------------
Now that the Dynamic Web program (index.php) has created the cookie, the server transmits the following HTTP header content to the browser:
http/1.1 OK
server:apache/2.2.6 (WIN32) php/5.2.6
date:fri,23 Mar 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
---------------------------------------------------------------------------
This will save a cookie file on the client and save the $c variable
When requested again, the data in the cookie is passed to the server, such as the HTTP request header below:
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
http://www.bkjia.com/PHPjc/327476.html www.bkjia.com true http://www.bkjia.com/PHPjc/327476.html techarticle Copy the code as follows: PHP $_cookie["counter"]? ($c =$_cookie["Counter"]+1):($c =1); Setcookie ("Counter", $c, Time () +60); echo "B Welcome to your first." Font color= #ff0000 ". $c." /font Times visit ...