Spring Boot cookie handling¶
Cookie handling in Spring Boot is primarily managed through the Servlet API, utilizing the HttpServletResponse object to add cookies to a response and the HttpServletRequest object to retrieve cookies from a request^[100-InBox__整理書籤.md].
Creating Cookies¶
To send a cookie to the client, a developer creates a new Cookie object—specifying a name and value—and adds it to the response using the response.addCookie() method^[100-InBox__整理書籤.md].
Reading Cookies¶
To access cookies sent by the client, the request.getCookies() method is used.^[100-InBox__整理書籤.md] This returns an array of Cookie objects, which can be iterated over to find a specific cookie by name^[100-InBox__整理書籤.md].
Related Concepts¶
- Spring Boot
- [[Servlet API]]
- [[HTTP Session]]
Sources¶
^[100-InBox__整理書籤.md]