当前位置:网站首页>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.
边栏推荐
- Two methods of implementing inverted strings in C language
- 埃氏筛选法:统计素数个数
- LeetCode26:删除有序数组中的重复项
- Interviewer: How to deal with Redis big key?
- APP自动化测试框架-UiAutomator2基础入门
- Several ways to draw timeline diagrams
- TF生成均匀分布的tensor
- matlab neural network ANN classification
- 凸集与凸函数
- Byte side: Can TCP and UDP use the same port?
猜你喜欢

Unity2D_背景粒子效果

《强化学习周刊》第57期:DL-DRL、FedDRL & Deep VULMAN

SQLi-LABS Page-2 (Adv Injections)

编程时请选择正确的输入法,严格区分中英文

Word怎么制作双面席卡?使用Word制作双面席卡方法

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

TF生成均匀分布的tensor

蓝牙模块的分类和对应的属性特点

How to fix Windows 11 not finding files

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?
随机推荐
Photometric Stereo 光度立体法三维重建
Leetcode 93 IP addresses
kvm虚拟机出现启动不了,NOT available,PV大于分区
Ali Ermi: Without accept, can a TCP connection be established?
角度和弧度的相互换算
Word怎么制作一张标准的答题卡?
Optimization of SQL Statements and Indexes
Several ways to draw timeline diagrams
QGIS编译SIP的问题
Interpretation of the paper (DropEdge) "DropEdge: Towards Deep Graph Convolutional Networks on Node Classification"
L3-2 至多删三个字符 (30 分)
SecureCRT 设置超时自动断开连接时长
knn到底咋回事?
Pagoda measurement - building LightPicture open source map bed system
什么是IDE(集成开发环境)?
STC8H development (15): GPIO drive Ci24R1 wireless module
supervisor 命令操作大全「建议收藏」
SecureCRT强制卸载
Access Characteristics of Constructor under Inheritance Relationship
场效应管Mosfet之雷卯Leiditech对应英飞凌Infineon