Brief
The session can be understood as: The user opens a browser, clicks multiple hyperlinks, accesses multiple Web resources on the server, and then closes the browser, the entire process becomes a session.
"Some of the problems we have to solve during the session"
* Each user interacts with the server in the process, each will have some data, the program to find ways to save each user's data.
Specific example: the user clicked on the hyperlink through a servlet to purchase a product, the program should save the user purchase of goods, so that when the user clicks the checkout servlet, the checkout servlet can get the user goods for the user checkout.
"Cookie Brief"
Cookies are client-side technology. The program writes each user's data in the form of a cookie to the user's respective browser. When users use a browser to access Web resources on the server, they take their own data. So the Web resources are processing the user's own data.
"Session Brief"
Session is a service-side technology, using this technology, the server at run time can be used for each user's browser to create a unique Session object , because the session for the user browser exclusive, so users access to the server's Web resources, Can put their own data in the respective session, when the user to access other Web resources on the server, the other Web resources from the user's own session to remove data for the user Service.
"Cookie Api--javax.servlet.http.cookie class"
The Javax.servlet.http.Cookie class is used to create a cookie,response interface that also defines a Addcookie method that is used to add a corresponding Set-coookie header field to its response header.
Similarly, a getcookies method is defined in the request interface, which is used to obtain the cookie submitted by the client.
[Common methods are as follows]
Public Cookie (String name,string value)
SetValue () and GetValue ()//set and get the value of the cookie
Setmaxage () and Getmaxage ()//Set up and get the expiry date of the cookie
SetPath () and GetPath ()//
SetDomain () and GetDomain ()
GetName ()
15_ Session Technology _cookie