Start to learn the relationship between Asp.net -- sessionid and session

Source: Internet
Author: User

1. Cookie

The cookie is stored on the client. the header set-Cookie returned by the server is created, saved, and deleted by the browser upon expiration. By default, the cookie life cycle is the browser process cycle. The server can also explicitly specify the cookie retention time. The browser sets the cookie retention time based on the specified cookie and saves it to the client hard disk. Cookie is the content of the HTTP protocol specification and an international standard.

 

2. Session

Session, which is stored on the server and used to store data in one session. What is a session? There is no standard definition, which is determined by the programmer. If it represents a session, that is, how to separate different sessions, generally through sessionid, each session has its own ID card number, that is, sessionid. Sessionid is a string that is generally stored on the client through cookies. When a browser sends a request, the sessionid is included, so that the server can determine the session of the request through sessionid. The default session lifecycle is 20 minutes, and the sliding survival policy is used.

 

3. Relationship between sessionid and session

In this case, the life cycle of the cookie storing sessionid is set to one year, and the session cycle is set to 20 minutes. If the browser does not access the server within 20 minutes after a session is created, the session created 20 minutes ago is released, and the sessionid in the cookie still exists, however, the server has no session corresponding to this sessionid. In this case, another session can be created based on the same sessionid. An employee ID and employee ID can only correspond to one or no employee at a fixed time, but at different time points, the same employee number can correspond to different employees. Because employees can resign and new employees at any time, and employee numbers can always be retained.

Related Article

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.