The core of the Web Cookie

Technical Session
http protocol is a stateless protocol. In order to satisfy interact data between multiple requests, we launched a technical session.
The concept
sessions:
one session is the time from the client and server to establish a connection start to the client or the server disconnects so far. Intermediate request and response process may be performed multiple times.
Classified
according to different storage locations, we have technical sessions divided into two categories.
Client session technology:
Cookie
server-side session technology:
the Session
Cookie
creation:
direct new can, Cookie Only arg constructor. Cookie is a key data format.
Cookie (String name, String value)
set cookie:
response.addCookie (cookies C)
obtaining Cookie
cookie [] request.getCookies ()
Principle
When we set a cookie, in response to the first bottom actually added to a set-cookie header . Which set up the cookie key pair.
When we send the request, the browser will automatically conform to the rules of cookie into the request header. Use cookie cookie header carrying value pair to the server.

Guess you like

Origin www.cnblogs.com/maomaodesu/p/12079004.html