Cookie technology is a very controversial technology. Since its birth, it has become a focal point of debate among network users and web developers. Some network users, even some senior Web experts, are also dissatisfied with its generation and promotion. This is not because of the weak functionality of cookie technology or other technical performance reasons, it is only because they think that the use of cookies poses a threat to the privacy of network users. Because the cookie is a small text file stored by the web server in the user's browser, it contains information about the user (such as the ID number and password, the way the user purchases the website, or the number of times the user visits the site ).
So what about Cookie technology? Does it bring personal privacy hazards to network users? Let's take a look at the following content and try again.
(1) Cookie technology Overview
In the development history of web technology, the emergence of cookie technology is a major change. First, Netscape introduced Cookie technology in its Netscape Navigator browser. Since then, the World Wide Web Association began to support cookie standards. Later, it was promoted by Microsoft (because Microsoft's IIS Web server adopts the ASP technology to a large extent and uses the cookier technology ), that is, Microsoft Internet Explorer fully supports Cookie technology. Up to now, most browsers support the cookie technology or are at least compatible with the cookie technology.
1) What is Cookie?
According to the definition in Netscape official documentation, cookie is a method in which the server or script can maintain information on the customer's workstation under the HTTP protocol. Cookie is a small Guangxi file saved on the user's browser by the Web server, it can contain information about the user (such as the ID number, password, the user's way of shopping on the web site, or the number of times the user visits the site ). The web site can access cookie information whenever the User links to the server.
In general, the browser uses one or more restricted files to support cookies. These files are called cookie files on machines that use Windows operating systems and Magic cookie files on Macintosh machines. These files are used by websites to store Cookie data. Websites can insert information in these cookie files, which has some side effects on some network users. Some users think that this has resulted in a violation of personal privacy. Worse, some users think that cookie is an infringement of personal space and brings security hazards to users' computers.
Currently, some cookies are temporary, while others are continuous. Temporary cookies are only saved in the browser for a specified period of time. Once the specified period is exceeded, the cookie will be cleared by the system. For example, in PHP, cookies are used to track user processes until the user leaves the website. A persistent cookie is saved in the user's cookie file, and can still be called when the next user returns.
When a cookie is saved in a cookie file, some users think that this will cause a big problem. Some users are worried that cookies will track users' online surfing habits, such as those types of websites and activities they love. Fear that once such personal information falls into the hands of some people with ulterior motives, the individual may become the object of a lot of advertising spam, or even be accidentally damaged. However, this worry will not happen because users outside the website cannot cross the website to obtain cookie information. Therefore, it is impossible to apply cookies for this purpose. However, some browser developers have no choice but to make an acquaintance response due to incorrect understanding of users and "spread by text" (for example, Netscape navigator4.0 and Internet assumer3.0 both provide cookie blocking options ).
The long-awaited result of cookie technology is that many browser developers are forced to provide flexible cookie control functions in their browsers. For example, the two mainstream browsers Netscape Navigator and Internet Explorer process cookies in this way: Netscape navigator4.0 can not only receive cookies for warning, but also shield them; internetexplorer3.0 can also block cookies. However, in Internet assumer4.0, you can only receive warnings and do not provide blocking options. However, in Versions later than Internet assumer4.0, the cookie blocking option is added.
In addition, many of the latest technologies can even block cookies on browsers that cannot block cookies. For example, you can set cookie files to different types to restrict the use of cookies. However, unfortunately, many website pages will be rejected if you want to completely block cookies. Today, many web site developers fall in love with the powerful functions of cookie technology. For example, the use of session objects is inseparable from the support of cookies.
Although there are still some network users who are happy with the cookie debate today, the vast majority of network users are still inclined to accept cookies. Therefore, we do our best to use cookie technology to develop our web pages.
2) How does cookie work?
To understand the cookie, you must understand its working principles. Generally, the cookie is returned from the server to the browser through HTTP headers. First, the server uses the set-Cookie header in the response to create a cookie. Then, the browser uses the cookie header to include the created cookie in its request, in addition, it is returned to the server to complete the demonstration of the browser.
For example, a cookie named login is created to contain the visitor's information. When a cookie is created, the server header is shown below. Assume that the visitor's registration name is "Michael Jordan ", the created cookie attributes, such as path, domain, and expires, are also specified.
Set-COOKIE: Login = Michael Jordan; Path =/; domain = msn.com;
Expires = Monday, 01-Mar-99 00:00:01 GMT
The above header will automatically add a record to the cookie file of the browser computer. The browser assigns a cookie named "login" to "Michael Jordon ". Note: during actual transmission, the cookie value is encoded by the URL of the urlencode method.
After the HTTP header containing the cookie value is saved to the cookie file of the browser, the header notifies the browser to return the cookie to the server through a request that the Cookie Path is ignored to complete the authentication of the browser.
In addition, some attributes of the cookie are used to limit the use of the cookie. For example, the domain attribute can restrict cookie sending on the browser side. In the preceding example, the cookie can only be sent to the specified server, instead, it will never go to other websites such as www.hp.com. The expires attribute specifies the retention period of the cookie. For example, the cookie above is saved in the browser for only one second on January 1, March 1, 1999. Of course, if there are too many cookies in the browser that are beyond the permitted scope of the system, the browser will automatically delete it. The attribute path is used to specify the directory path in which the cookie will be sent to the server.
Note: After the browser creates a cookie, the cookie will be carried in the header for every request for the website. However, the cookie will never be sent for requests from other websites. In addition, the browser will keep sending until the cookie expires.
Cookie and its usage (1)