The HTTP protocol (http://www.w3.org/Protocols/) is a "one-way" protocol.
The server cannot actively connect to the client and can only passively wait and reply to the client request. The client connects to the server, issues an HTTP request, the server processes the request, and returns an HTTP Response to the client, which ends the HTTP request-response cycle.
We see that the HTTP protocol itself does not support server-side saving of client state information. As a result, the concept of session is introduced in Web server to hold the client's state information.
Here, an image metaphor is used to explain how the session works. Suppose that Web server is a store's storage, HTTP request is a customer, the first time to the storage, the administrator put the customer's belongings in a certain cabinet (this cabinet is equivalent to a session), and then put a number of cards to the customer, As a package voucher (this number is the session ID). The next time the customer (HTTP Request) comes in, the number card (Session ID) will be given to the Administrator of the Depository (Web Server). The administrator finds the corresponding cabinet (session ID) according to the number plate (session), according to the request of the customer (HTTP request), the Web server can remove, replace, add items in the cabinet (session), the Web The server can also invalidate the counter (Session) of the customer (HTTP Request) with the number and number plates. The doctor became of the customer (HTTP Request) is very large, and the administrator will re-remind the customer to remember their number (Session ID) when the customer goes back (http Response). The next time the customer (HTTP Request) comes in, it comes back with the number card.
We can see that the Session ID is actually transmitted between the client and the server via HTTP request and HTTP response.
We see that the number plate (Session ID) must be included in the HTTP request. For the exact format of the HTTP request, see HTTP protocol (http://www.w3.org/Protocols/). Here is a simple introduction.
In Java WEB Server (that is, servlet/jsp server), the Session ID is represented by Jsessionid (see servlet specification
session_id Explanation of Cookies