Session Principle Analysis

Source: Internet
Author: User

What is Sesson?

In short, it is a session-level cookie, plus a group of scattered lists in the server memory.

When you close your browser, the cookie disappears.

This cookie is stored in the browser cache instead of on the disk.

 

Session legends

It is said that sessions and Applications in Web applications are stored on the server, while cookies are stored on the client.

In fact, sessions exist on both the client and server.

If you have already written a Session in development, open the Firefox browser, and clear the cookie, you will find a cookie of session_id (the java developer will see JSESSIONID). After deletion, the Session will become invalid.

If you open the IE browser, the Session still exists after the cookie is cleared. I don't know how to deal with IE. Maybe it only clears the Session from the disk.

 

Session implementation principle

1. When a Session is created, the server generates a unique sessionid and uses it to generate a cookie that will expire when the browser is closed.

2. Then, add a data item associated with this sessionid to the hash table.

For example, Session ["UserName"] = 23;

If sessionid is 123, a row is appended to the hash table.

Sessionid username

123 23

3. When the browser submits the information to the server, it uses sessionid = 123 to retrieve the Session information of the user from the scattered list.

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.