Ask a novice about a problem (only a few lines of code)
Source: Internet
Author: User
Ask a novice question (only a few lines of code)
$count =$_cookie[nam];
$count + +;
Setcookie ("Nam", $count, Time () +300);
echo "Welcome!"
You are the first person to visit the site $count ";
?>
Why is this code able to record the number of visitors? Is the cookie not stored on the guest's computer? Isn't it possible to log only the number of times this browser has been accessed?
------Solution--------------------
discuss
$count =$_cookie[nam];
$count + +;
Setcookie ("Nam", $count, Time () +300);
echo "Welcome!"
You are the first person to visit the site $count ";
?>
Why is this code able to record the number of visitors? Is the cookie not stored on the guest's computer? Isn't it possible to log only the number of times this browser has been accessed?
------Solution--------------------
Explore
The $_cookie is stored on the client. However, each time an HTTP request is made, the browser sends the cookie corresponding to the Web site to the server side.
This is the value of PHP's $_cookie super variable.
If you want to set a new value, the server then sends an HTTP header via Setcookie () to set the
------Solution--------------------
discuss
$count =$_cookie[nam];
$count + +;
Setcookie ("Nam", $count, Time () +300);
echo "Welcome!"
You are the first person to visit the site $count ";
?>
Why is this code able to record the number of visitors? Is the cookie not stored on the guest's computer? Isn't it possible to log only the number of times this browser has been accessed?
------Solution--------------------
This is just an example. It's not true.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service