当前位置:网站首页>会话和饼干,令牌
会话和饼干,令牌
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
边栏推荐
- 虚拟机查看端口号进程
- 深度学习知识点杂谈
- mPEG-DSPE 178744-28-0 Methoxy-polyethylene glycol-phosphatidylethanolamine linear PEG phospholipids
- 这些数组技巧,我爱了
- Natural language processing related list
- CAS:474922-22-0 Maleimide-PEG-DSPE 磷脂-聚乙二醇-马来酰亚胺简述
- 人脸识别AdaFace学习笔记
- 科学研究用磷脂-聚乙二醇-活性酯 DSPE-PEG-NHS CAS:1445723-73-8
- unicloud cloud development record
- ROS之service传输图片
猜你喜欢

Sqlite column A data is copied to column B

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

PyTorch学习笔记08——加载数据集

VS通过ODBC连接MYSQL(二)

VS2017 connects to MYSQL

RuntimeError: CUDA error: no kernel image is available for execution on the device问题记录

mysql 事务原理详解

MW: 3400 4-Arm PEG-DSPE four-arm-polyethylene glycol-phospholipid a saturated 18-carbon phospholipid

Session和Cookie,Token

变分自编码器VAE实现MNIST数据集生成by Pytorch
随机推荐
Understanding of objects and functions in js
JS写一段代码,判断一个字符串中出现次数最多的字符串,并统计出现的次数JS
TransactionTemplate 事务编程式写法
Sourcery插件(自动提升代码质量)
Tensorflow相关list
Attention based ASR(LAS)
Fluorescein-PEG-DSPE 磷脂-聚乙二醇-荧光素荧光磷脂PEG衍生物
DSPE-PEG-COOH CAS: 1403744-37-5 Phospholipid-polyethylene glycol-carboxy lipid PEG conjugate
深度学习知识点杂谈
opencv之图像二值化处理
Nmap的下载与安装
超参数优化-摘抄
mPEG-DMPE Methoxy-polyethylene glycol-bismyristyl phosphatidylethanolamine for stealth liposome formation
VS2017连接MYSQL
break and continue exit in js
This in js points to the prototype object
DC-CDN学习笔记
softmax函数详解
After unicloud is released, the applet prompts that the connection to the local debugging service failed. Please check whether the client and the host are under the same local area network.
VTK:Could not locate vtkTextRenderer object.