当前位置:网站首页>Cookie operation
Cookie operation
2022-07-05 07:20:00 【Sun Tianyang】
1. take cookie Back to the browser
// Create a Cookie
Cookie cookie = new Cookie(“cookieName”);
// Settings are readable only by browsers
cookie.setHttpOnly(true);
// Set retention duration -1 Means not to delete
cookie.setMaxAge(-1);
// Set up cookie Reserved path , It can be shared in the same application server
cookie.setPath("/")
response.addCookie(cookie);
2. obtain cookie
Cookie[] cookies = request.getCookie();
if(cookies == null || cookies.length == 0) {
return null;
}
for(Cookie cookie : cookies) {
if(“cookieName”.equals(cookie.getName())) {
return cookie.getValue();
}
}
return null;
边栏推荐
- Interpretation of the earliest sketches - image translation work sketchygan
- PHY drive commissioning --- mdio/mdc interface Clause 22 and 45 (I)
- Import CV2 prompt importerror: libgl so. 1: Cannot open shared object file: no such file or directory
- list. files: List the Files in a Directory/Folder
- Special training of C language array
- Jenkins reported an error. Illegal character: '\ufeff'. Class, interface or enum are required
- Powermanagerservice (I) - initialization
- [idea] efficient plug-in save actions to improve your work efficiency
- 氫氧化鈉是什麼?
- 第 2 章:小试牛刀,实现一个简单的Bean容器
猜你喜欢
Idea to view the source code of jar package and some shortcut keys (necessary for reading the source code)
2022年PMP项目管理考试敏捷知识点(7)
What if the DataGrid cannot see the table after connecting to the database
Ros2 topic (VIII)
【软件测试】03 -- 软件测试概述
CADD课程学习(5)-- 构建靶点已知的化合结构(ChemDraw)
[software testing] 02 -- software defect management
Ros2 - node (VII)
[node] NVM version management tool
Tshydro tool
随机推荐
【软件测试】06 -- 软件测试的基本流程
【Node】npm、yarn、pnpm 区别
U-Boot初始化及工作流程分析
HDU1232 畅通工程(并查集)
[vscode] recommended plug-ins
【obs】x264编码:“buffer_size“
Hdu1232 unimpeded project (and collection)
Don't confuse the use difference between series / and / *
arcgis_ spatialjoin
Raspberry pie 4B arm platform aarch64 PIP installation pytorch
并发编程 — 死锁排查及处理
苏打粉是什么?
iNFTnews | 喝茶送虚拟股票?浅析奈雪的茶“发币”
Word import literature -mendeley
第 2 章:小试牛刀,实现一个简单的Bean容器
现在有html文件,和用vs制作的mvc(连接了数据库),怎么两个相连?
Idea to view the source code of jar package and some shortcut keys (necessary for reading the source code)
[node] differences among NPM, yarn and pnpm
Powermanagerservice (I) - initialization
网易To B,柔外刚中