• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

JSP and cookies

yes4me2

Member
This JSP code doesn't return the same Max age. Any idea why, and how can I fix that?


Cookie cookie = new Cookie("test", "some value");
cookie.setMaxAge(86400);
response.addCookie(cookie);
try
{
Cookie[] cookies = request.getCookies();
for (int i=0; i<cookies.length; i++)
{
if (cookies.getName().equals("test"))
{
out.print("1st result:"+ cookies.getValue() +"___"+ cookies.getMaxAge() +"<br />");
}
}
out.print("2nd result:"+ cookie.getValue() +"___"+ cookie.getMaxAge() +"<br />");
}
catch(Exception e)
{
}


Result is:
1st result:some value___-1
2nd result:some value___86400
 
Back
Top