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

边栏推荐
- [C language] simple implementation of mine sweeping game
- Deep learning classification network -- alexnet
- LeetCode 83. Delete duplicate elements in the sorting linked list
- Cookie plugin and localforce offline storage plugin
- Bgp Routing preference Rules and notice Principles
- Redis Key-Value数据库 【秒杀】
- Shenji Bailian 3.53-kruskal
- Format check JS
- The real definition of open source software
- Flutter 混合开发: 开发一个简单的快速启动框架 | 开发者说·DTalk
猜你喜欢

CNN visualization technology -- detailed explanation of cam & grad cam and concise implementation of pytorch

sudo提权

Happy Lantern Festival | Qiming cloud invites you to guess lantern riddles

Google Go to sea entrepreneurship accelerator registration countdown 3 days, entrepreneurs pass through the guide in advance collection!

加密压缩文件解密技巧

51单片机——ADC讲解(A/D转换、D/A转换)

Deep learning classification network -- Network in network

谷歌出海创业加速器报名倒计时 3 天,创业人闯关指南提前收藏!

【C语言】简单实现扫雷游戏

Zabbix Server trapper 命令注入漏洞 (CVE-2017-2824)
随机推荐
格式校验js
穀歌出海創業加速器報名倒計時 3 天,創業人闖關指南提前收藏!
Data playback partner rviz+plotjuggler
Monitoring uplink of VRRP
如何使用MITMPROXy
Shenji Bailian 3.53-kruskal
ZABBIX server trap command injection vulnerability (cve-2017-2824)
Zhuanzhuanben - LAN construction - Notes
Introduce uview into uni app
Lambda expressions and method references
Stc8h8k series assembly and C51 actual combat - keys allow key counting (using falling edge interrupt control)
servlet的web.xml配置详解(3.0)
Redis key value database [primary]
从设计交付到开发,轻松畅快高效率!
Stc8h8k series assembly and C51 actual combat - digital display ADC, key serial port reply key number and ADC value
Format check JS
LeetCode 90. 子集 II
Some experience of exercise and fitness
Eco express micro engine system has supported one click deployment to cloud hosting
Spark overview