15_ Session Technology _cookie

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.