I understand that a JSP session cookie is not persistent. Once all browser instances are closed, the session cookie is gone.
Created Jan 17, 2002
Derek Illchuk
What this does is it rewrites the non-persistent session cookie created automatically (non-persistent because no expiration is specified) to the same one, but having an expiration (using setMaxAge()). The setPath must be identical to the original, and the name (JSESSIONID) must be identical, as well. Now, because of the expiration, this cookie is not deleted on exit, and contains the exact info as the original (using getId()).
In the JSP page, I inserted the following:
<%
Cookie sessionCookie = new Cookie("JSESSIONID", session.getId());
sessionCookie.setMaxAge(1800);
sessionCookie.setPath("/examples");
response.addCookie(sessionCookie);
%>
It works great! Remember, the session information is still on the server until it times out (half an hour).