Managing cookies |
On of the benefits of the HttpSession class is that cookies are managed for you automatically. By default all cookies are accepted.
Disabling cookies
You can disable cookies using the HttpSession#setCookies method.
Example
// create new HttpSession HttpSession session = new HttpSession();
// disable cookies session.setAllowCookies(false);
Get cookies for a specified hostname
You can obtain cookies accepted for a specified hostname using the HttpSession#getCookiesForHost method. This will return a java.util.Vector of cookie headers.
Example
// get cookies accepted from www.server.com Vector v = session.getCookiesForHost("www.server.com");
|