Current location - Recipe Complete Network - Complete breakfast recipes - What are cookies? What's your use? What happens if it is deleted?
What are cookies? What's your use? What happens if it is deleted?
The record mark of an Internet browser is called a Cookie.

Cookies are also called cookies.

Cookies are a technology that allows the website server to store a small amount of data in the client's hard disk or memory, or read data from the client's hard disk. Cookies are very small text files that are put on your hard disk by the Web server when you browse a website. It can record your user ID, password, the pages you visited, the time you stayed and other information. When you come to the website again, the website can read Cookies and get your relevant information, so you can take corresponding actions, such as displaying a welcome slogan on the page, or allowing you to log in directly without entering an ID or password.

It can be regarded as your ID card in essence. But Cookies cannot be executed as code, nor can they spread viruses, and they are exclusive to you and can only be read by the server that provides them. The saved pieces of information are stored in the form of "name-value pair", which is just a named piece of data. A website can only get the information it puts on your computer, it can't get the information from other Cookies, and it can't get anything else on your computer.

Most of the contents in Cookies are encrypted, so the average user seems to be just meaningless alphanumeric combinations, and only the CGI processor of the server knows their true meaning.

Cookies are text files or data stored in the hard disk of the user's computer transmitted by the website we visit, so their storage location in the hard disk is closely related to the operating system and browser used. In the computer of Windows 9X system, the storage location of cookie file is C:WindowsCookies, and in the computer of Windows NT/2000/XP, the storage location of cookie file is C: \ documents and settings \ user name \ cookies.

Cookie files in the hard disk can be read through a web browser, and the command format is: user name @ website [number ].txt. For example, the file name of a cookie in the author's computer is ch@ 163[ 1].txt. It should be noted that Cookies in the hard disk are text files, not programs.

Cookies settings

Select "Set/View Files" in the "General" tab of IE's "Tools/Internet Options" to view all Cookies saved in your computer. These files are usually named in the format of user@domain, where user is your local user name and domain is the domain name of the website you visit. If NetsCape browser is used, it is stored in "C:PROGRAMFILESNETS- CAPEUSERS". Unlike IE, NETSCAPE uses a Cookie file to record cookies of all websites.

We can set cookies appropriately: open the privacy tab in Tools/Internet Options (note that this setting only exists in IE6.0/IE7.0, and other versions of IE can adjust the security level of cookies by clicking the Custom Level button in the Security tab of Tools/Internet Options). It can usually be adjusted to the "medium high" or "high" position. Most forum sites need to use Cookie information. If you never go to these places, you can set the security level to "block all Cookies". If you only want to block Cookie from individual websites, you can click the Edit button to add the websites to be blocked to the list. In the Advanced button option, you can set first-party cookies and third-party cookies. The first-party Cookie is the Cookie of the website you are browsing, and the third-party Cookie is the Cookie sent to you by the website you are not browsing. Generally, you should choose "Reject" for third-party Cookie. If you need to save Cookie, you can use ie's "Import and Export" function to open "File/Import and Export" and follow the prompts.

Writing and reading Cookies

Cookies collection is a data collection attached to the Response object and the Request object, and it needs to be used before the Response or the Request.

The syntax used to send Cookies to clients is usually:

When a nonexistent cookie set is set, it will be created on the client, and if the cookie already exists, it will be replaced. Because cookies are sent to the client as part of the header information of HTTP transmission, the code that sends cookies to the client is usually placed before the tag of the HTML file sent to the browser.

If users want to read cookies, they must use the cookie collection of the requested object in the following ways:

It should be noted that the browser can exchange Cookies data with the server only before the server downloads any data to the browser. Once the browser starts to receive the data downloaded from the server, the data exchange of Cookies will stop. To avoid mistakes, reply. Buffer=True should be added in front of programs and browsers.

The application of Cookies

Almost all website designers will use Cookie when designing websites, because they all want to provide a more friendly and humanized browsing environment for users who browse websites, and at the same time, they can collect visitors' information more accurately.

Website visitor number management

Because of the use of proxy server and cache, the only way to help the website accurately count the number of visitors is to establish a unique ID for each visitor. Using Cookie, websites can accomplish the following tasks: measure how many people have visited it; Determine how many visitors are new users (that is, first-time visitors) and how many are old users; Determine how often users visit websites.

Usually, website designers use background databases to achieve the above goals. When a user visits a website for the first time, the website will create a new ID in the database and send it to the user through a Cookie. When the user visits again, the website adds 1 to the counter corresponding to the user ID to get the user's visit times or judge whether the user is a new user or an old user.

Customize the appearance of web pages according to users' preferences.

Some website designers provide users with the right to change the content, layout and color of web pages, allowing users to input their own information, and then modify some parameters of the website through this information to customize the appearance of web pages.

Realize the "shopping basket" and other functions in e-commerce websites.

You can use Cookie to record the user's ID, so that when you put something new in the shopping basket, the website can record it and record your ID in the database of the website. When you "pay the bill", the website can know what is in your shopping basket by searching all your choices in the database through ID.

In general, the database of a website can store the content you choose, the pages you visit, the information you fill in the form and so on. A Cookie containing your unique ID is stored in your computer.

Shortcomings of biscuits

Although Cookie are widely used, they can achieve some functions that other technologies can't. But there are also some imperfections, which bring inconvenience to the application.

The problem that many people use a computer.

Any computer used in public or multiple computers used in the office or at home will be used by more than two people at the same time. In this way, when you use it to shop in the online supermarket, the online supermarket or website will leave a Cookie on this machine, and someone may try to shop with your account in the future, which brings the possibility of insecurity. Of course, this will not be a problem on some computers that use multi-user operating systems such as Windows NT or UNIX. Because under the multi-user operating system, Cookie of different accounts are placed in different places.

When Cookies are deleted

If your browser doesn't work properly, you can delete all temporary Internet files on your computer. However, once you do this, you will lose all the cookies. When you visit the website again, the website will think you are a new user and assign you a new user ID and a new Cookie. In this way, the proportion of new and old users in the website statistics will be biased, and it will be difficult for you to restore the parameter selection saved in the past.

When a person uses more than one computer

Some people often use more than one computer in one day. For example, there is a computer in the office, a computer at home, and a laptop for mobile office. Unless the website uses special technology to solve this problem, you will have three different Cookies files on these three machines, and any website you visit on these three machines will treat you as three different users.

Prevent cookies from leaking

Want to know whether the websites you visit have Cookies written on your hard disk or memory? Just follow the following steps, you can know and control the Cookies information of the website you are visiting.

Step 1 Click Tools Internet Options in the IE window to open the Internet Options Settings window;

Step 2 Click the "Security" tab in the "Internet Options" setting window, and then click the "Custom Level" button to enter the "Security Settings" window;

Locate the "Cookies" setting item in the "Security Settings" window. There are two sub-options under the "cookie" setting, in which "Allow cookies to be stored on your computer" refers to the cookie file stored on the hard disk of the user's computer; "Allow the use of each conversation cookie (no storage)" refers to the cookie information stored in the memory of the user's computer. Cookie files stored in hard disk are permanent, while cookie information stored in memory is temporary. If you want IE to prompt when all Cookies from the website are about to be received, you can select the "Prompt" item in the above two sub-options. Of course, you can also choose "Enable" to let IE accept all Cookies information (this is also the default option for IE); If "Forbidden" is selected, the website is not allowed to store cookies on your computer, and the website cannot read cookies that already exist on your computer.

IE6.0 provides more reliable personal privacy and security protection measures, allowing users to control how much information the browser sends. A privacy tab has been added to the Internet Options window (Figure 1), so that users can directly set the privacy level when browsing, and control the Cookies used by other sites on the computer as needed. If the website we are browsing uses Cookie, a yellow exclamation mark will appear in the browser status bar. Double-click to open the privacy report dialog box, where users can view specific privacy policies, or directly click the "Settings" button in the "Privacy" tab above to adjust the security privacy level.

The "Delete cookie" button has been added in the "General" tab (Figure 2), which is convenient for users to directly clear the cookies of this machine. In addition, some options to further improve security (such as clearing temporary Internet files when closing the browser) have been added in the Advanced tab of Tool Options. In fact, how to better protect personal privacy and security is the key technology in Microsoft's next generation. " NET "strategic software. Now IE6.0 has tried to take the first step.

In addition, because the information of Cookies is not all stored in the computer in the form of files, some information is stored in memory. For example, when you browse a website, the web server will automatically generate cookies in memory, and when you close IE browser, it will automatically delete cookies. Then neither of the two methods described above works, and we need to use the registry editor to modify the system settings. It should be noted that please make a backup before modifying the registry so that you can recover smoothly after problems occur.

Run Regedit and find the following key values: HKEY _ Local _ Machine \ Software \ Microsoft \ Windows \ Current Version \ Internet \ Set Scachespecial Paths Cookies, which is the key value of cookies in memory. Delete the key value. At this point, no matter what form Cookies exist, we don't have to be afraid anymore. (Note: The new version of Windows may no longer be located in this registry directory)

Finally, putting an end to Cookies can enhance the information security of your computer, but it also has some disadvantages. For example, on some web pages that need Cookies support, there will be some inexplicable errors. A typical example is that you can't use the free mailboxes of some websites in the future.

Cookie cheating

By analyzing the format of Cookie, we know that the last two items are its URL path and domain name, and the server relies on these two parameters to identify cookies. Generally, when we want to browse a website, the URL we enter is its domain name, which needs to be converted into an IP address through the domain name management system DNS before we can connect. If you can make some settings on DNS and map the IP address of the target domain name to other sites, you can illegally access the Cookie of the target site.

Cookie cheating is actually very simple. For example, in the installation directory under Win9X, there is a file named hosts.sam After opening it in text, you will see this format:127.0.0.1localhost.

After setting up, you can localize the domain name resolution, just add IP and domain name to the file according to the above format and save it as hosts. Hosts file can actually be regarded as a local DNS system, which can be responsible for interpreting domain names as IP addresses. Its priority is higher than DNS server, and its implementation is a part of TCP/IP protocol.