Technical Session: a session comprises multiple requests and responses
*: The client first sends a request to the server, session establishment, until one party disconnects, then the session is terminated
Function: a plurality of times in a session request range, among the shared data.
Client session technology: Cookie
Cookie data is stored in the client
How to Use Cookie
1 Create a Cookie object, bind data
Cookie cookie = new Cookie(String name, value)
2 Send Cookie
response.addCookie(cookie )
3 Cookie get data acquiring
Cookie [] cookies = request.getCookies ()
The principle:
Based on response header set-Cookie request header and the cookie
4Cookie details
1 can be sent more than Cookie, Cookie create multiple objects and multiple calls request.addCookie () J can
Cookie time is saved multiple times in your browser?
1 By default, the session ends, the data is lost
2 persistent storage
Use setMagAge (int sencond)
Positive, designated Cokkie survival time can also be saved corresponding milliseconds
Negative: Default
0: Delete Cookie
3Cookie how storage Chinese:
Before tomcat8, the data needs to be converted into encoded url variable transmission
Tomcat8 later. We have to support Chinese, but still does not support special characters, you need to use url encoded for storage, transmission
Cookie shared problem:
In a tomcat deploy multiple web projects, how to let data sharing
setPath () The default path for the virtual path, if you want to share, set its path to the default path / to.
How to be shared among different Tomcat:
Cookie subdomain can share data in the parent domain ()
Cookie features and functions (3):
1Cookie data stored in the client (which is the client session technology)
2 corresponds to a browser Cookie has a limit size and number, with the number under a Cookie domain is 20, a size of 4kb Cookie
Less sensitive 3Cookie general store data, (it is not safe, (A little conversation technology person, you can see even extract the information))