当前位置:网站首页>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.
边栏推荐
猜你喜欢

万字总结:分布式系统的38个知识点

Install Mysql8.0 on windos, and solve the problem of re-login exception ERROR 1045 (28000)

【双链表增删查改接口的实现】

Ali Ermi: Without accept, can a TCP connection be established?

poj 3070 Fibonacci(简单矩阵连乘)

Word第一页空白页怎么删除?删除Word第一页空白页方法教程

APP自动化测试框架-UiAutomator2基础入门

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?

TF生成均匀分布的tensor

XXE-XML外部实体注入-知识点
随机推荐
mysql多表左链接查询
Definition and Basic Operations of Linear Tables
[Essay] To the friends of the 19th issue
6个规则去净化你的代码
Ali Ermi: Without accept, can a TCP connection be established?
STC8H Development (15): GPIO Drives Ci24R1 Wireless Module
【云原生】4.2 DevOps 精讲篇
角度和弧度的相互换算
Deceptive Dice(期望计算)
蔚来杯2022牛客暑期多校训练营7 CFGJ
论文解读(DropEdge)《DropEdge: Towards Deep Graph Convolutional Networks on Node Classification》
必看设计干货|易知微设计师是怎么做标准可视化设计服务的?
Interviewer: How to deal with Redis big key?
Unity_物体自转
Unity2D_背景粒子效果
Daily practice of PMP | Do not get lost in the exam -8.8 (including agility + multiple choice)
URL Protocol web page to open the application
2021(ICPC)亚洲区域赛昆明站(CGHIJLM)
定投的基金
knn到底咋回事?