当前位置:网站首页>Cookie, session, token
Cookie, session, token
2022-08-09 23:12:00 【Want to buy food】
Cookies, sessions, and tokens appear to solve the shortcoming of http statelessness. They are all returned by the server and used for authentication.Cookies are stored on the client side and are not secure.There is a risk of being intercepted by illegal users.
Cookies are stored in the browser's cache, and the expiration time is determined by the server. As long as the browser is closed, it will become invalid.It can also be persisted locally.
For example, if the client sends a request to the server, the server will return cookies in the setcookie field of the response header.Expiration.
As for the session, it is stored on the server side, and the server side will generate a sessionid and pass it through a cookie.For example, when the client sends a request, the server will put the sessionid in the setcookie and return it to the client. When the client makes a login request, it will carry this value. After the server gets it, let’s talk about it first.There are two ways to save, one is stored in a file, the other is placed in the database.The server gets the sessionid sent by the client and goes to its own local to find the corresponding sessionid, and then verifies whether the user with the key sessionid is the client of the request. If so, it will respond.
However, there will be a problem. If hundreds of millions of users send requests at the same time, the server needs to save the sessionid of hundreds of millions of users, so it will cause serious pressure on the performance of the server.
The emergence of Token can solve the cross-domain access problem of microservice deployment.
The user login request goes to a special authentication service for authentication. After the authentication is successful, the encrypted token is returned. After the client gets it, it is saved., the next time the user accesses, it will bring this token to make a request, and the requested service will take this token to the authentication center to see if it belongs to the user. If it is, then it will be passed and the response will be returned.
Token validity time:
①Within 15 minutes
②Generally 15 days
This value is configurable.
边栏推荐
猜你喜欢

PMP daily practice | didn't lost a 8.9 (including agile + multi-select)

DSPE-PEG-Silane, DSPE-PEG-SIL, phospholipid-polyethylene glycol-silane modified silica particles

Several ways to draw timeline diagrams

Word文档怎么输入无穷大符号∞

UE4_定序器控制蓝图对象
6个规则去净化你的代码

Cholesterol-PEG-Thiol, CLS-PEG-SH, Cholesterol-PEG-Sulfhydryl for improved solubility

AI识万物:从0搭建和部署手语识别系统

Excel如何打出正负号?Excel打出正负号的方法

Simulation of Water Temperature Control System Based on Fuzzy PID Controller
随机推荐
STC8H开发(十五): GPIO驱动Ci24R1无线模块
[corctf 2022] section
宝塔实测-搭建LightPicture开源图床系统
6个规则去净化你的代码
hdu 3341 Lost's revenge(dp+Ac自动机)
Tensorflow中使用convert_to_tensor去指定数据的类型
AI识万物:从0搭建和部署手语识别系统
knn到底咋回事?
AI Knows Everything: Building and Deploying a Sign Language Recognition System from Zero
C语言中的文件是什么?
CVPR22 Oral | shunt through multi-scale token polymerization from attention, code is open source
普源精电上半年扭亏为盈,高端产品持续发力!你看好仪器界“华为”吗?
DSPE-PEG-Silane, DSPE-PEG-SIL, phospholipid-polyethylene glycol-silane modified silica particles
Puyuan Jingdian turned losses into profits in the first half of the year, and high-end products continued to develop!Are you optimistic about "Huawei" in the instrument industry?
Several ways to draw timeline diagrams
fixed investment fund
np中的round函数,ceil函数与floor函数
STC8H development (15): GPIO drive Ci24R1 wireless module
TF中使用zeros(),ones(), fill()方法生成数据
字符串哈希(2014 SERC J题)