I'm creating and attaching a cooking for my application with some useful information.
But this information is not accessible after that.
The problem is that when I try to attach too much information, my cookie is not passed forward. When I try to attach few information it's OK.
My questions:
- What is the max length for cookies values?
- If it's a bug, there is any workaround for Tomcat 5.5?
I'm creating my cookie using the following code:
Cookie cookie = new Cookie(key, value);
cookie.setPath("/");
response.addCookie(cookie);
And for retrieving my cookie, I'm using this code:
private static String getCookieValue(HttpServletRequest request, String name) {
boolean found = false;
String result = null;
Cookie[] cookies = request.getCookies();
if (cookies != null) {
int i = 0;
while (!found && i < cookies.length) {
if (cookies[i].getName().equals(name)) {
found = true;
result = cookies[i].getValue();
}
i++;
}
}
return (result);
}