!
!
!2021-10-22 17:19:21
HTTP Cookies
!, 2021-10-22 17:19:21

What opportunities do cookies provide that are not in php and js?

I tried to figure it out before, but I didn't get it

Cookies (English cookie, lit. - "cookies") - a small piece of data sent by a web server and stored on the user's computer. The web client (usually a web browser) sends this piece of data to the web server as part of an HTTP request whenever it tries to open a page on the corresponding site. Used to save data on the user side


- the server can simply send data to the client via ajax and the client will store them in its storage

, maybe cookies were invented before ajax appeared and the localstorage or sessionStorage storage in the browser?

Cookie alternatives:
HTTP Authentication
The HTTP protocol includes basic authentication and encryption, which allow access to a page only when the user enters the correct username and password. If the server requests this, the browser contacts the user and, having received the necessary data, saves and uses them to access other pages without requiring the user to enter them again. From the user's point of view, the effect is the same as when using cookies: the username and password are required only once, and then the user is granted access to the site. With Basic Authentication, the username/password combination is sent unencrypted to the server with every browser request. This means that if someone intercepts the traffic, they will be able to get this information and subsequently use it.

Client Side Saving
Some web browsers allow a page to store information locally for later retrieval. Internet Explorer, for example, supports storing information in history, favorites, XML storage, or allows direct saving of a web page to disk[43].

JSON Web Tokens A
JSON Web Token (JWT) is a self-contained package of information that can be used to store information about a user's identity and identity. This allows them to be used instead of session cookies. Unlike cookies, which are automatically attached to every HTTP request by the browser, JWTs must be explicitly attached by the web application to every HTTP request.

DOM Window.name
All modern web browsers can store a fairly large amount of data (2-32 MB) via JavaScript using the window.name DOM property. This data can be used in place of session cookies and is also cross-domain. The technique can be combined with JSON/JavaScript objects to store complex sets of session variables[44] on the client side.

Browser cache
A web cache can also be used to store information that can be used to track individual users. This method takes advantage of the fact that the web browser will use the resources stored in the cache instead of downloading them from the website when it determines that the most recent version of the resource is already in the cache.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Aetae, 2021-10-22
@Aetae

Cookies are NOT part of php or js. Cookies are a separate proprietary standard primarily used to store shared state between systems communicating over the HTTP protocol.
Those. their main task is generally outside the framework of programming languages.

T
Talyan, 2021-10-22
@flapflapjack

Well for example the PHPSESSID cookie is set to identify the session.
You are a master at asking questions.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question