read value
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
String cookieName = "username";
Cookie[] cookies = request.getCookies();
if (cookies != null) {
for (Cookie cookie : cookies) {
if (cookie.getName().equals(cookieName)) {
//do something
//value can be retrieved using #cookie.getValue()
}
}
}
%>
set value
Cookie cookie = new Cookie ("username",username);
response.addCookie(cookie);
delete value
Cookie cookie = new Cookie ("username",username);
cookie.setMaxAge(0);
response.addCookie(cookie);