How does cookies work on the Internet?

zhaozj2021-02-17  49

How does cookies work on the Internet?

The cookies on the Internet are incredible. But it has its own unique vitality, and cookies begins to pay a wide focus of the media after the intense debate caused by the Internet privacy protection in February 2000.

On the other hand, cookies provides the ability to become easy to make, almost every major website designer will use cookies because cookies can provide easy collection of information about the correct site accessers.

We will take a look at the basic technical details of cookies and some of its features.

Cookies foundation

In April 2000, I saw an article about Internet privacy protection in a very affected newspaper, in which the definition of cookies is included in this article, as follows:

Cookies is a program placed on your hard drive. They reside on your computer to collect information about everything you do on the Internet, and the Web site can read all the information collected at any time.

In the news, this is fair, the problem is that there is no correct in this definition. Cookies is not a program. It can't do a lot of things like programs, so they can't collect any information, and they can't collect you. Any information on the machine.

Here is a relatively appropriate definition of cookies:

A cookies is a text where the web server is stored in the user's hard drive, and the cookies allows a WEN site to store some text information in the user's machine, and can re-get it later. This text-based information stores some "key-value" pairs.

For example, a Web site is to create a unique ID number for each visitor and store this number into the cookies of each visitor's machine.

If you use Microsoft's IE to browse a web, you can see all the cookies on your machine in your hard drive, usually they will reside in directory C: / Windows / Cookies (Win98), or C: / Documents and Settings / user name / cookies (Win2000, Win XP) Next, when I see this directory of my machine, I found 165 files. Each is a text file containing the "Key-Value" pair, and each site has a cookies file.

You can see that every file in this directory is a simple, ordinary text file, you can see which web site is placed in your machine through the file name (this information is also saved in the file content ), You can open each file to view its content.

For example, I have visited the site goto.com, this site will place a cookie on my machine, the name of this cookie file is goto.com, including the following information:

Userid a9a3bece0563982d www.goto.com/

Site goto.com has placed a single "key-value" pair on my machine, the name of the key is UserID, the value of the key is A9A3BECE0563982D, I first visited the goto.com site, the site assigned a unique ID gives me and stores this ID to my machine.

Most sites are only only in your machine to store a cookie of a user ID, but this is not limited, and a site can store a lot of "key-value" right on your machine, as long as it likes.

The cookies file contains only these simple "key-value" pairs, it is not a program, so it can't "do" anything, a Web site can only re-obtain itself to your hard drive, it can't be from other Cookies files have been made in the cookies file, nor can you see anything else of your machine. How to move cookies data

As you can see in the above chapters, cookie data is a simple Web site placed on your hard disk for text, all cookies files. The Web site saves these data, then you can get it back, a Web site can only retrieve it yourself in your machine, you can't see other cookies, you can't see anything on your machine.

Cookie data moves below:

n If you enter the URL of the web in your browser, the browser will send a request like this URL's Web site, for example, enter the URL in the browser: http://www.verizon.com, browser Send the request to the Verizon's web server, requesting it home page.

n When the browser sends a request, it will view the cookie file related to the domain www.verizon.com, if there is a cookie related to www.verizon.com, the browser will associate the relevant cookie "key - value "Send the data with the request to the server. If there is no cookie related to www.verizon.com, the browser does not send a cookie to the server.

N Verizon's web server receives cookies data and a page HTTP request. If you receive a cookie "key-value" pair, Verizon's web server will be able to use them.

n If you do not receive a cookie "key-value", Verizon's web server can know that you have not accessed this site before, the server establishes a new user ID, and send it back to your browsing When the user ID "key-value" is sent to your machine, your hard disk will reside on the "key-value" for this site.

n Web Server You can change the "Key-Value" or join a new "key-value" right when you access the site.

With the "key-value", there is some other information related to this "key-value" to the client, one of which is the validity period of the cookie, and the other is the path (in order to associate differently in the same site. Cookie).

You can control this process, you can set up when you send cookies when you send your machine in your browser, you accept or refuse.

How to use cookies in the Web site

Cookies is developing because it solves the big problem, broad understanding, and cookies allows a site to save status information on your machine. This information allows the web site to remember what state is in your browser, A UserID This simple "key-value" is allowed to know that you have visited this site before, and the status is "your browser visits this site once", and the site can know you from this visit. User ID.

The Web site uses cookies through a lot of ways, below is some examples:

N sites can accurately know how many visitors are actually accessing sites, which can eliminate the unique ways of correct statistical site access to each visitor? Set a unique ID and there is a cookie, with a cookie, the site can: u, how many visitors arrive.

u Decide how many new visitors, how many visitors are again.

u Determines the frequency of accessor access

Web site To do this is by using a database, a visitor first arrives, the site creates a new User ID in the database, and sending this user ID as cookie to the client, this user will access again At this site, the site will add access times in the User ID record associated with this user in the database, so how long does this user access to it.

n Different from each user, the site can store the user's parameters, for example, some sites offer the ability to change content, layout, color settings, which can provide custom weather information based on your postal coding.

Most sites seem to save user parameters in the site database, in addition to the information stored in cookies, but to store an actual value in the "key-value" pair, there is another one. method:

n E-commerce site enables similar shopping blue and quick payment, with cookies containing the User ID to track customers and put different goods into your shopping blue, every item you put in shopping, will be stored In the database, in your User ID, when you pay, the site knows which products you have purchased. If there is no cookie or similar technique, it will not be possible to implement the above functions.

In all these examples, note that the database is used to store the items you selected in the site, the page you are browsing, the information you provide in the form, etc., all the information is saved in the database, Only your user ID is used to identify the user's identity in the cookie stored on the client.

Cookies problem

Cookies is not an ideal state machine, but it is indeed a lot of other things that can't do, and below is some of the disadvantages of cookies:

N often use a machine to use any machine used in public applications, and many machines used in the office or many machines used in the home are multiplayer. Let us see that you are using a multi-person machine (for example, in the library machine) to buy goods in an online store, the store's website will leave some of your settings information on this machine, then Some people use this machine to purchase goods in this online store, this website will provide some settings.

n cookies is deleted - if your browser comes out to seek technical support, technical supporters want you to do what you do is to ask you to first delete all Internet temporary files on your machine, when you do this You will lose all your cookies files. When you visit a site again, the site will think you are a new user and give you a new User ID, and some personal settings you have set before this site will not exist.

n Use multiple machines - people often use more than one machine within one day, for example, using a machine in the office, using a machine at home, on the road, the laptop may be used on the road. This will use three unless cookies on three machines, and the same person will be treated separately as three users.

转载请注明原文地址:https://www.9cbs.com/read-29384.html

New Post(0)