A Comparison of Four Session Tracking Technologies

Session tracking is a flexible mechanism. Although HTTP is a stateless protocol, session tracking technology makes state programming on the Web possible. There are currently four common session tracking technologies: URL rewriting, hidden form fields, cookies, Session.

1 Hide form fields

<input type="hidden" id="xxx" value="xxx">
  • Features
    • (Parameter storage) The parameters are stored in the request entity, so there is no length limit, but the GET request method is not supported, because GET has no request entity
    • (Cookies disabled) Works even when cookies are disabled
    • (persistence) there is no persistence, it ends as soon as the browser is closed

2 URL rewriting

You can append parameters to the URL and send them with the server's request. These parameters are key/value pairs

  • Features
    • (Parameter storage) The parameters are stored in the url and have a length limit of 1024
    • (Cookies disabled) Works even when cookies are disabled
    • (persistence) there is no persistence, it ends as soon as the browser is closed

A cookie is a small file saved by the browser that contains multiple key-value pairs

The server first uses the Set-Cookie response header to transmit multiple parameters to the browser, and the browser saves them as cookies. Subsequent requests to the same server use the
Cookie request header to transmit these parameters to the server.

  • Features
    • (Parameter storage) The parameters are stored in the request header, and there is also a length limit, but this limit is the limit of the server configuration and can be changed
    • (cookies disabled) may disable cookies
    • (Persistent) The browser can save the cookie for a period of time, during which the cookie remains valid

4 Session

Based on one of the first three session tracking technologies (usually based on cookie technology, if the browser disables cookies, URL rewriting technology can be used), only one parameter is transmitted in each request: JSESSIONID, the session id, the server according to This session id opens up a session memory space to store other parameters

  • Features
    • All session data is stored on the server, which reduces the pressure on the client and the network, but aggravates the pressure on the server
    • Since it is based on one of the first three session technologies (cookies, url rewriting, hidden form fields), it also has several corresponding characteristics.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325084932&siteId=291194637