As one of the three giants of traditional e-commerce (the others are Alibaba and Pinduoduo), the difficulty of Dongzi's interview questions is also average. Generally speaking, it is not as difficult as the other two interviews, and of course the salary is not as high as the other two. Among them, Pinduoduo's salary is the most outrageous, especially in the past few years. I heard that they poached developers from the same industry and offered them salaries that were two to three times their original salaries. It's really abnormal (but I like it). Dongzi's interview questions are as follows: picture Most of the interview questions can be answered on my website (www.javacn.site), so I won’t go into details here. Today we will only talk about: What are the differences between Cookie, Session and Token? 1. What are the differences between Cookie, Session and Token?Cookies, Sessions, and Tokens are usually technologies used to save user login information, but there are big differences between the three. Simply put, Cookies are suitable for simple state management, Sessions are suitable for scenarios where user sensitive information needs to be protected, and Tokens are suitable for state-independent authentication and authorization. Analysis of Token state independence: In the traditional session-based authentication method, the server needs to save the user's session state in the backend and manage the session through the Session ID. The Token mechanism does not need to save any user status information on the server. When the login is successful, the server only needs to generate a unique Token value through a certain algorithm, and then send this Token to the client for storage (stored in localStorage or sessionStorage). Note that the server does not store this Token value at this time. The server only verifies but does not save this Token. This is called "state independence". This can reduce the burden of the server to store and manage the session state, so it is more suitable for large systems and distributed systems. Specifically, the differences between Cookie, Session and Token are as follows:
2.What is the relationship between Cookie and Session?To be precise, the implementation of Cookie has nothing to do with Session, but the implementation of Session requires the help of Cookie. The implementation process of the Session mechanism is as follows:
So by default, the Session uses Cookies to complete the transmission of identity identification, so that the server can associate the Session ID with the saved session information to find a specific logged-in user. Therefore, by default, the Session mechanism relies on Cookies. 3. Can Session still be used after disabling Cookies?From the above, we know that by default, the Session mechanism is implemented by relying on Cookies. So does it mean that after disabling Cookies, the Session mechanism will no longer be usable? Actually, it is not. In addition to the default, we can use cookies to pass the Session ID, we can use some special means to pass the Session ID by ourselves, so as to get rid of the situation where the Session cannot be used after disabling cookies, such as the following two implementation methods:
The above methods can pass the Session ID to the server (although it is a bit troublesome). Then on the server, we can obtain and map the Session ID passed above. In this way, the work of passing and matching the logged-in user is manually completed, and the Session mechanism can continue to be used. summaryCookies, Sessions, and Tokens are usually used to save user login information, but there are big differences between the three: Cookies are suitable for simple state management, Sessions are suitable for scenarios where sensitive user information needs to be protected, and Tokens are suitable for state-independent authentication and authorization. By default, Sessions use the Cookie mechanism to pass Session IDs, but when Cookies are disabled, Session IDs can still be passed using special means, and the Session mechanism can still be used. Tokens do not save session information on the server side, so they are more suitable for large and distributed projects. |
<<: 6G is getting further and further away from us
>>: Analysis of the Art of Communication between Computers
114 Public DNS Universal high-speed version: DNS ...
BandwagonHost has also released a Double 11 disco...
VIAVI Solutions, Inc. (NASDAQ: VIAV) will showcas...
OneTechCloud is a Chinese hosting company founded...
Preface: With the continuous upgrading of bandwid...
Recently, an article has attracted attention and ...
Since the beginning of the 21st century, cloud co...
At the beginning of the month, we shared Megalaye...
spinservers has released a promotion for March, o...
At present, we are in the Internet era, and Inter...
SD-WAN is more than just an alternative to Multip...
TNAHosting is a relatively early established fore...
As an important part of the country's new inf...
The hottest word in the technology field in 2016 ...
5G will be put into large-scale commercial use as...