search
HomeCommon ProblemWhat is the function of cookies?

What is the function of cookies?

Nov 02, 2020 am 11:32 AM
cookie

Function of cookies: 1. Cookie is a plain text file saved on the client; 2. Cookie files must be supported by the browser, and cookies can be blocked in the browser.

What is the function of cookies?

Function of cookie:

Cookie is a plain text file saved on the client. For example, txt file. The so-called client is our own local computer. When we use our own computer to access a web page through a browser, the server will generate a certificate and return it to my browser and write it to our local computer. This certificate is a cookie. Generally speaking, cookies are plain text files written by the server to the client. Let's take a look at the cookie files that general websites write to us as follows:

Cookie files must be supported by the browser, and the browser can be set to block cookies. In this way, the server cannot write cookies to the client. Currently, most browsers support cookies. Such as Google, IE, Firefox, etc. Generally speaking, cookies cannot be blocked, because sometimes cookies must be used when accessing a website. Otherwise the website will not be accessible.

So, here comes the problem, what exactly do we use this thing for?

For example, if we go to the website to buy something, I open the web page for buying shoes. At this time, I send a request and tell the server that you will return me some shoe information and list. At this time, the client The connection to the server is disconnected.

The user visited again and added a pair of shoes to the shopping cart and then the connection was disconnected. At this time, the user wants to buy a pair of pants again, and the user also adds the pants to the shopping cart. At this time, the connection is disconnected again. At this point, the user sends another request saying, I want to check out, and then the user opens a new checkout interface. Now the question is, how does the server know the items in the shopping cart that the user just added? How does the server know that this user bought something?

So now cookies are used. Before the emergence of seesion, most websites save requested content through cookies, and the server displays specific content based on the user. That is to say, if we do not use cookies, we will not be able to see the items in the shopping cart in the browser. This is similar to the browser's favorites. If we have collected it, we will see our collection next time we open the browser window. s things. In other words, the cookie saves a before and after state. If I don't use cookies, I won't know whether I have added it to the shopping cart. So why does this happen? In the final analysis, it is because of the connectionless nature of http.

Related learning recommendations: Programming video

The above is the detailed content of What is the function of cookies?. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool