Ask a newbie (only a few lines of code) & lt ;? Php $ count $ _ COOKIE [nam]; $ count ++; setcookie (& quot; nam & quot;, $ count, time () + 300); echo & quot; welcome! & Lt; br & gt; you are the $ count visitor to this site & quot; ask a newbie question (only a few lines of code)
$ Count = $ _ COOKIE [nam];
$ Count ++;
Setcookie ("nam", $ count, time () + 300 );
Echo "Welcome!
You are the $ count guest ";
?>
Why can this code record the number of visitors? Isn't the cookie stored on the visitor's computer? Isn't this the only way to record the number of visits to the browser?
------ Solution --------------------
Discussion
$ Count = $ _ COOKIE [nam];
$ Count ++;
Setcookie ("nam", $ count, time () + 300 );
Echo "Welcome!
You are the $ count guest ";
?>
Why can this code record the number of visitors? Isn't the cookie stored on the visitor's computer? Isn't this the only way to record the number of visits to the browser?
------ Solution --------------------
Discussion
$ _ COOKIE is stored on the client. However, when an http request is sent, the browser sends the Cookie corresponding to the website to the server.
This is the value of the $ _ COOKIE Super variable in php.
If you want to set a new value, the server sends an http header through setcookie () to set
------ Solution --------------------
Discussion
$ Count = $ _ COOKIE [nam];
$ Count ++;
Setcookie ("nam", $ count, time () + 300 );
Echo "Welcome!
You are the $ count guest ";
?>
Why can this code record the number of visitors? Isn't the cookie stored on the visitor's computer? Isn't this the only way to record the number of visits to the browser?
------ Solution --------------------
This is just an example. Not true