当前位置:网站首页>The difference between session and cookies
The difference between session and cookies
2022-07-02 06:13:00 【Radish goo】
1、cookie Data is stored on the client ,session Data on the server .
2、cookie Because the data is stored on the client , So it's not very safe , Others can analyze the local COOKIE And carry on COOKIE cheating
Should be used in consideration of safety session.
3、session It's time-sensitive , Usually follow tomcat, It's usually 30 minute ; But not every 30 Refresh every minutes , Generally, there is an action , Automatically move the time back 30 minute
Cookie Generally, there is no expiration time , It's usually the client , We will clear the browser cookie The operation of
For example, our login page , During the first visit , Will be in cookie Save our corresponding sessionid, The relevant information of the corresponding account is stored in session in , When we add it later 、 Delete and other operation requests , You don't need to enter the account password every time . Will pass in cookie Medium sessionid Go to the server and find the corresponding session Is it overdue , If there is expiration , Will jump to the login page ; If session Not expired , You can directly
How do you use it? :
@PostMapping("/postStudent")// Insert students
public String postStudent(@RequestBody String name ,HttpServletRequest req,HttpServletResponse res) {
req.getSession().setAttribute("student", "xiaoming");
System.out.println(req.getSession().getId());
System.out.println(name);
return null;
}
adopt req.getSession().setAttribute("student", "xiaoming"); Put the corresponding session For storage , At this time, the sessionid Store in cookie in ;
边栏推荐
- ESP8266与STC8H8K单片机联动——天气时钟
- LeetCode 47. 全排列 II
- Keepalived installation, use and quick start
- 【C语言】筛选法求素数
- Ros2 --- lifecycle node summary
- Invalid operation: Load into table ‘sources_orderdata‘ failed. Check ‘stl_load_errors‘ system table
- Talking about MySQL database
- Redis Key-Value数据库 【高级】
- Go learning notes integration
- 492. Construction rectangle
猜你喜欢
Unity Shader 学习笔记(3)URP渲染管线带阴影PBR-Shader模板(ASE优化版本)
Redis key value database [primary]
AttributeError: ‘str‘ object has no attribute ‘decode‘
Compte à rebours de 3 jours pour l'inscription à l'accélérateur de démarrage Google Sea, Guide de démarrage collecté à l'avance!
Deep learning classification network -- Network in network
Sumo tutorial Hello World
51 single chip microcomputer - ADC explanation (a/d conversion, d/a conversion)
Happy Lantern Festival | Qiming cloud invites you to guess lantern riddles
Web components series (VIII) -- custom component style settings
Shenji Bailian 3.54-dichotomy of dyeing judgment
随机推荐
LeetCode 27. Removing Elements
Deep learning classification network -- Network in network
深入了解JUC并发(二)并发理论
492. Construction rectangle
Use some common functions of hbuilderx
深入学习JVM底层(四):类文件结构
ES6的详细注解
Redis key value database [advanced]
51单片机——ADC讲解(A/D转换、D/A转换)
LeetCode 77. combination
LeetCode 78. subset
Redis key value database [seckill]
【C语言】筛选法求素数
Web page user step-by-step operation guide plug-in driver js
WLAN相关知识点总结
Jetpack Compose 与 Material You 常见问题解答
ESP8266与STC8H8K单片机联动——天气时钟
LeetCode 27. 移除元素
Unity Shader 学习笔记(3)URP渲染管线带阴影PBR-Shader模板(ASE优化版本)
Detailed steps of JS foreground parsing of complex JSON data "case: I"