Jsessionid and the difference between cookies and their relationship

Source: Internet
Author: User
Tags session id

1. Session:

Session is for each user, the value of the variable is saved on the server side, through SessionID to distinguish between different customers, session is based on cookie or URL rewrite. By default, cookies are used to create an output cookie called Jsessionid, or "Session cookie", to differentiate between persistent cookies (commonly referred to as cookies). The Session cookie is stored in the browser and is not written on the hard disk, but after the browser's cookie is banned, the URL is encoded using the Encodeurl or Encoderedirecturl method of the Response object. The Web server passes the SessionID in a URL rewrite, and the user can see strings such as jsessionid=a09jhghkhu68624309uty84932 in the address bar.
Usually session cookie is not used across windows, when the user opened a new browser to enter the same page, the system will give users a new SessionID, so that the purpose of sharing information can not be achieved, at this time to save SessionID in persistent Cookie, and then read it in a new window, you can get the SessionID of the previous window, so that through the combination of Session cookie and persistent cookie, the cross-window session tracking is realized.
How the session Works
In terms of the implementation of the session, it seems like this:
(1) When a session is started, the server generates a unique value called SessionID (as if it was obtained by taking the process ID).
(2) The server then opens up a piece of memory corresponding to the SessionID.
(3) The server then writes the SessionID cookie to the browser (some of which are reflected in the source code of the Web page).
(4) There is a process within the server, monitoring the activity of all sessions, if there is a session timeout or active shutdown, the server will release the memory block.
(5) When the browser is connected to IIS (server) and the requested ASP (scripting language) is used within the session, IIS (server) attends the SessionID in the browser cookie.
(6) The service then checks to see if the SessionID memory is valid.
(7) If valid, the value in memory is read out.
(8) If it is not valid, create a new session.
Attention:
(1) In the large views of the site, the session is not insured, our past sites often encountered in the session of the value is incorrect (may appear duplicate session ID).
(2) The session ID cannot be obtained from the cookie file on the hard disk, and can only be read by JavaScript if you want to know your session ID on the client.


2. Cookies:

A cookie is a very short piece of information that can be placed on a computer's hard drive automatically by the Web site. Through a cookie, the website can identify you for the first time or visit it again. The website can also use cookies to understand what you are interested in and to collect information about the user, such as the time limit for recording automatic login, the recording of user names, the restriction of voting only once, and so on. When you browse certain websites, the website program stores a small cookie (as a text file) on your hard drive without your knowledge. If you want to know what kind of cookies you have on your computer, look for a folder of cookies in the Windows directory.

Cookie Removal

If you don't want to store cookies on your computer, you can change your browser's settings. The specific method is as follows (ie, for example):
Start IE, find "tools/internet Options/Security/Custom Levels" and you'll see how to handle different options for cookies. This method is suitable for IE 5.0 version

Jsessionid and the difference between cookies and their relationship

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.