Class Cookies
java.lang.Object
tech.riemann.nif.auth.service.Cookies
Cookie工具类
提供Cookie的添加、读取等常用操作
主要功能: 1. 向HTTP响应中添加Cookie(支持path、domain、secure、httpOnly等配置) 2. 从HTTP请求中获取指定名称的Cookie值(忽略大小写)
使用示例:
// 添加Cookie
Cookies.addCookie(response, "token", "xxx", 60, CookieOptions.builder()
.httpOnly(true)
.secure(true)
.path("/")
.build());
// 获取Cookie值
String token = Cookies.getCookieValue(request, "token");
- Author:
- Kerbores(kerbores@riemann.tech)
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCookie(jakarta.servlet.http.HttpServletResponse response, String name, String value, int age, Cookies.CookieOptions options) 向 HTTP 响应中添加 CookiegetCookieValue(jakarta.servlet.http.HttpServletRequest request, String name) 从 HTTP 请求中获取指定名称的 Cookie 值
-
Constructor Details
-
Cookies
public Cookies()
-
-
Method Details
-
addCookie
public void addCookie(jakarta.servlet.http.HttpServletResponse response, String name, String value, int age, Cookies.CookieOptions options) 向 HTTP 响应中添加 Cookie- Parameters:
response- HTTP 响应对象name- Cookie 名称value- Cookie 值age- Cookie 过期时间(分钟)options- Cookie 配置选项,包含 path、domain、secure、httpOnly 等属性
-
getCookieValue
-