Who can explain vividly how the conversation is understood, can you give an example?

Source: Internet
Author: User
Does the browser create a new session for each page you open?

Reply content:

Does the browser create a new session for each page you open?

The session is maintained some continuous access state, HTTP is stateless, you first open http://www.xxx.com/1/and then open http://www.xxx.com/2/or you refresh the page, on the server side how do I know you are the same person? IPV4 is not reliable, you a company may be an external IP, if after a few levels of non-transparent agent, it is even more likely.

But this want to maintain the state demand is a hard demand ah, the total solution ah. If you want to come up with each request, with a unique ID is not done, if the first time without, give him a designated. In a specific implementation, usually through a Cookie or attached to the URL, this ID is SessionID, usually different server environment will have a fixed name, such as PHP is usually called PHPSESSID, Servlet is usually called jsessionid, etc., when You can, however, take a different name, as long as you reach the goal of passing "ID identification".

Say what the server SESSION is going on. Server to the SESSION is equivalent to a key-value database, the library can be a file system, can also be other relational database, key value database. Through the browser sent by the SessionID, the corresponding session data, this data, is usually said session data.

Did you mention that "every page opened by a browser is counted as a new session?" ", this problem is very good, here to say the life cycle of the session, in fact, should be divided into two pieces, one is the life cycle of the session ID, one is the life cycle of the session data.

Session ID life cycle: At present the more common way to pass SessionID is through a cookie, a cookie records about a few properties: name, value, path, domain name, expiration time, etc., you mentioned "open a page", I think should be corrected to "open browser", This expiration time is often referred to as the session period, which means that the browser is closed and re-opened, and the original cookie is invalidated (i.e. no longer passed). However, not all SessionID must expire, you can set the expiration date for your SessionID cookie, and you can add this time each time you visit, so that even if you close and open the browser, you can continue to pass the cookie as long as the user does not manually empty it. Keep your state in mind.

Session Data Life cycle: On the server side, we can also set an expiration time for the session, such as more than 30 minutes without read and write failure (that is, delete or do not return). Of course, different server-side software environments may have different default settings and Setup methods for this time.

Say something about logging in.

How does user login relate to this Session? Simply put, the login is in your Session data record your user identity, that is, the current SessionID with the user (ID) directly associated with, of course, if you are happy, your SessionID can be exactly the same as the user ID (preferably encrypted or confused).

Session and login status does not necessarily have a relationship, such as you on an e-commerce website, you do not log in also the same as the goods into your shopping cart, on the e-commerce website, he can put your shopping cart data in the Session,cookie,localstoreage, Sesisonstoreage, the first on the server side, the second client, the server side of the synchronous delivery, the latter two are pure client. No matter what, at this time on the e-commerce website only need to know that a temporary customer ABCDEF (SessionID) Take this pile of things, until you want to check out, you need to sign up to indicate your identity, so that you pay and send to your long-filled address. If the e-commerce doesn't think he has a lot to deal with after you (affair) and doesn't want to know who you are, the payment process is simple (sweep QR code) and he doesn't need you to log in.

The most obvious examples are the numerous AD platforms that embed code everywhere to track your cookies (in fact, to record and analyze some of your browsing status, browsing history) so that he knows which sites you've been to and what you like, and you can direct your ads. But in order to avoid unnecessary trouble, he does not want to know who you are (or if you do not want to know his presence), he will not need to play you a login dialog box; In this case, you are "anonymous" on his platform, but he can still understand you a lot.

Because I have done many years of development in the field of Internet advertising, every time with people to explain the example of advertising, others are very frightened, how to "kind" a cookie can "track" My browsing record?

That's not true.

The advertising platform will cooperate with the content website, let the content website embed a small piece of code, this code can be a JS, or

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.