Interview 5

1 small program how to maintain login state?


4483499-92ef141f76afee7a.png

I suddenly thought yesterday that the interviewer seems to mention the "session", "different from the session" and other words. Maybe I should pay attention to the principles underlying point?

2, how cooike and collaboration session (or contact)?

Session recording is another mechanism of customer status, except Cookie is stored in the client browser, and Session saved on the server. The client browser access to the server, the server to the client information recorded on the server in some form. This is the Session. Just look for the Session of the client when the client browser access again from the state on it.

Unique each user accessing the server will establish a session, the server that is how it identifies the user? In fact, while the user connections to the server, the server will automatically assign a SessionId.

While Session stored in the server, the client is transparent, it still needs to support the normal operation of the client browser. This is because the Session Cookie is required as identification. HTTP protocol is stateless, Session not based on whether the HTTP connection is determined for the same client, the server sends a so called Cookie JSESSIONID to the client browser, its value is the Session id (i.e. HttpSession.getId () The return value). According to the Session Cookie to identify whether the same user.

The Cookie is a server automatically generated, it is generally -1 maxAge property, showing only valid within the current browser, and each browser is not shared between windows, the browser will fail to close.

Check out the above information, I make a conclusion:

A cookie is stored on the client browser and the session is saved on the server. While the session is saved on the server, but its normal operation without the support of the client's browser. Because the HTTP protocol is stateless, Session can not be judged based on whether the HTTP connection is the same user, so the user connections to the server, the server will assign a sessionid to the client. This is the sessionid cookie. According to this session cookie to determine whether the same user.

Guess you like

Origin blog.csdn.net/weixin_34072857/article/details/90816560
Recommended