当前位置:网站首页>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 ;

边栏推荐
- Step by step | help you easily submit Google play data security form
- Lambda expressions and method references
- Unity Shader 学习笔记(3)URP渲染管线带阴影PBR-Shader模板(ASE优化版本)
- Detailed steps of JS foreground parsing of complex JSON data "case: I"
- TI毫米波雷达学习(一)
- 格式校验js
- Ti millimeter wave radar learning (I)
- Some experience of exercise and fitness
- Current situation analysis of Devops and noops
- MUI底部导航的样式修改
猜你喜欢
随机推荐
步骤详解 | 助您轻松提交 Google Play 数据安全表单
Error creating bean with name 'instanceoperatorclientimpl' defined in URL when Nacos starts
Lambda 表达式 和 方法引用
Keepalived installation, use and quick start
BGP routing optimization rules and notification principles
Shenji Bailian 3.52-prim
CNN visualization technology -- detailed explanation of cam & grad cam and concise implementation of pytorch
Frequently asked questions about jetpack compose and material you
外部中断无法进入,删代码再还原就好......记录这个想不到的bug
格式校验js
Mock simulate the background return data with mockjs
From design delivery to development, easy and efficient!
Contest3147 - game 38 of 2021 Freshmen's personal training match_ A: chicken
Ros2 --- lifecycle node summary
Go learning notes integration
51 single chip microcomputer - ADC explanation (a/d conversion, d/a conversion)
ZABBIX server trap command injection vulnerability (cve-2017-2824)
The real definition of open source software
Picture clipping plug-in cropper js
Zabbix Server trapper 命令注入漏洞 (CVE-2017-2824)








