DWQA QuestionsCategory: ProgramWhat are the differences and relations between cookie, session and rewriting URL?
Desert swordsman asked 8 months ago

In addition to using cookies, the web can also use session to record client status.
A session identifier is stored in a cookie. What is the relationship between the session identifier (sessionid) and the session?
If the browser forbids cookies, it is found on the Internet that the method of rewriting the URL can be used to save the session identifier on the URL,
Then the server parses the rewritten URL to get the sessionid.
Using session to record the client state can also complete the session. What’s the difference between session and cookie except for the location?
Isn’t session cookie based? Session is essentially still using cookies to complete the session, right?

2 Answers
Carson answered 8 months ago

From the question you ask, you don’t understand the principle of sessionThis postI suggest you take a good look at the following reference links
But I don’t think you’ll take a good look. I’ll give you a simple explanation to help you understand. Don’t take the part that you skip seriously
A session simply means that it exists by recording the identity. The client gives an identity and the session takes this identity as the session_ ID (that is, the identity of the client).
So we can know

There is no necessary connection between session and cookie

What are the common session implementations

  1. Cookie session
  2. url Session

Can session be used to record client status
This is not a proper question. You should know the essence of session. Session is realized by the identity provided by the client,
Session and cookie are used in completely different scenarios. Cookies exist for a period of time and remain until they have expired,
Therefore, the temporary state can be saved, but the session is different. When the browser is closed, you don’t even have your identity. If you keep? General cookies are used to save
Client temporary information, session records the user information maintained after login
The difference between session and cookie
The above question has basically answered this question. Of course, session is relatively safe. Cookie has no security for the user who can operate the machine. Session general user saves the user’s login information and stores it in the server. The server processes the server logic with session information. Cookie is stored in the client and general user It is designed to manage the temporary information and keep some information after the session is disconnected to process the client logic
If you still have questions, you can comment

ivanna answered 8 months ago

Session is saved on the server side and cookie is saved on the browser side
SESSION ID is an ID number issued by the server side to the browser.
Cookie is like a public envelope
In the process of a link access, the client can store the session ID in the cookie, so that each time a different URL is executed, when the server needs to check the session ID, it can get it through the cookie contained in the HTTP request.
When the cookie is disabled, you need to tell the server the session ID every time you request, so you can rewrite the access URL and add the session ID as a parameter, which can also achieve the purpose of identity confirmation