[Cookie] Briefly understand cookies and browsers

A cookie is a small piece of text information maintained by the browser, stored on the client, and passed between the web server and the browser along with user requests and pages.

The information contained in the cookie can be read by the web application each time the user visits the site.

There is a cookie privacy data option in the browser settings. If you open it, you can see the cookies of many visited websites:

Of course, you can also turn on the developer mode of the browser to view the specific cookie information of a site.

Session cookies and persistent cookies

Cookies are time-limited and are divided into two types according to their lifetimes:Session cookies and persistent cookies;

If does not set the expiration time, it means that the cookie life cycle is from creation to browser closing,As soon as you close the browser window, the cookie disappears. This type of cookie whose lifetime is the browser session is called a session cookie. Session cookies are generally not stored on the hard disk but in memory.

If sets the expiration time (setMaxAge(60*60*24)), the browser will set the cookie< a i=3>Save to the hard drive, close and open the browser again, these cookies will still be validuntil the set expiration time . Cookies stored on the hard drive can be shared between different browser processes, such as two IE windows. Different browsers have different ways of handling cookies stored in memory.

Guess you like

Origin blog.csdn.net/weixin_41989013/article/details/134736889