当前位置:网站首页>会话和饼干,令牌
会话和饼干,令牌
2022-07-31 06:24:00 【Forevermoremo】
Session
Session is a technology that records user information on the server side. Generally, Session is used to share data between the server side and the client side.
Cookies
Cookie is a technology that records user information on the client side. Because the http protocol is stateless, cookies are generated to solve this problem.
Cookies are stored in the browser's built-in Cookies.As shown:

Cookie is a piece of small text data not exceeding 4KB, consisting of a name (Name), a value (Value) and several other optional attributes used to control the validity period, security, and scope of use of the cookie.
The client requests the server, and if the server needs to record the user status, it uses the response to issue a cookie to the client browser.The client browser will save the cookie.When the browser requests the website again, the browser submits the requested address to the server together with the cookie.The server checks the cookie to identify the user's status.The server can also modify the content of the cookie as needed.
Session and Cookies
Session generally relies on cookies. Sessions are created to pass the sessionId through cookies, and then passed to the server when the client requests.Therefore, it is necessary to confirm whether the browser has enabled cookie storage.
Server-based authentication is as follows:
1. The user sends a request with a username and password.
2. Program verification, if the client request does not contain sessionId, the server creates a session for this client and generates a sessionId associated with this session, and returns the SESSIONID to the client.
4. The client stores the SessionId in Cookies, and each time a request is made, the browser will automatically carry the Cookie to the server.
5. Server-side retrieval.If the retrieval is successful, the requested data will be returned, and if the retrieval fails, an error code will be returned.
As shown:

Token
Token-based authentication is stateless, we do not need to store user information in the server or session.
The process of Token-based authentication is as follows:
1. The user sends a request with a username and password.
2. Program verification, after the verification is successful, the Token will be returned to the client.
4. The client stores the Token, and each access to the API carries the Token to the server.
5. The server side uses the filter filter to verify.If the verification is successful, the request data will be returned, and if the verification fails, an error code will be returned.
Each request token should be sent in the HTTP header to ensure that the HTTP request is stateless.We can allow the server to accept requests from all domains by setting the server property Access-ControlAllow-Origin:* .
The process is shown in the figure:

Summary
Session, Cookie, and Token are both used for data sharing between the server and the client.
Session is a server-based authentication. With the rise of Web mobile terminals, some memory overhead, scalability, and cross-domain problems are gradually exposed. Token can just solve these problems, although the server involves more,But it also facilitates our front-end to solve cross-domain problems.
Reference:
https://www.cnblogs.com/moyand/p/9047978.html
https://blog.csdn.net/deft_mkjing/details/53762277
边栏推荐
- 化学试剂磷脂-聚乙二醇-氨基,DSPE-PEG-amine,CAS:474922-26-4
- mPEG-DSPE 178744-28-0 甲氧基-聚乙二醇-磷脂酰乙醇胺线性PEG磷脂
- This in js points to the prototype object
- cv2.imread()
- VS通过ODBC连接MYSQL(二)
- Cholesterol-PEG-NHS NHS-PEG-CLS cholesterol-polyethylene glycol-active ester can modify small molecular materials
- Tensorflow相关list
- 2022年SQL大厂高频实战面试题(详细解析)
- 计算图像数据集均值和方差
- 自然语言处理相关list
猜你喜欢

qt:cannot open C:\Users\某某某\AppData\Local\Temp\main.obj.15576.16.jom for write

mPEG-DMPE 甲氧基-聚乙二醇-双肉豆蔻磷脂酰乙醇胺用于形成隐形脂质体

Fluorescein-PEG-DSPE Phospholipid-Polyethylene Glycol-Fluorescein Fluorescent Phospholipid PEG Derivatives

使用 OpenCV 提取图像的 HOG、SURF 及 LBP 特征 (含代码)

QT VS中双击ui文件无法打开的问题

wangeditor富文本编辑器上传图片以及跨域问题解决

CLS-PEG-FITC Fluorescein-PEG-CLS 胆固醇-聚乙二醇-荧光素简介

Fluorescein-PEG-DSPE 磷脂-聚乙二醇-荧光素荧光磷脂PEG衍生物

Cholesterol-PEG-DBCO 胆固醇-聚乙二醇-二苯基环辛炔化学试剂

日志jar包冲突,及其解决方法
随机推荐
这些数组技巧,我爱了
学习JDBC之获取数据库连接的方式
关于Iframe
Tensorflow相关list
mPEG-DMPE 甲氧基-聚乙二醇-双肉豆蔻磷脂酰乙醇胺用于形成隐形脂质体
我的训练函数模板(动态修改学习率、参数初始化、优化器选择)
Cholesterol-PEG-Azide CLS-PEG-N3 胆固醇-聚乙二醇-叠氮 MW:3400
MYSQL transaction and lock problem handling
Navicat从本地文件中导入sql文件
Cholesterol-PEG-Azide CLS-PEG-N3 Cholesterol-PEG-Azide MW:3400
MYSQL事务与锁问题处理
PyTorch学习笔记08——加载数据集
WeChat applet source code acquisition and decompilation method
Cholesterol-PEG-Thiol CLS-PEG-SH 胆固醇-聚乙二醇-巯基
Xiaomi mobile phone SMS location service activation failed
Redis-Hash
Cholesterol-PEG-Acid CLS-PEG-COOH Cholesterol-Polyethylene Glycol-Carboxyl Modified Peptides
cocos2d-x implements cross-platform directory traversal
Shell/Vim相关list
Global scope and function scope in js