William Pietri <william <at> scissor.com> writes:
>     request.getCookies().add(new Cookie("PreferredLanguage","en-us"));

Hi David and William,
I think you might need to try a slightly different method. What works for me is
creating a CookieSetting object, like this:

final CookieSetting cookie = new CookieSetting(COOKIE_NAME, cookieContents);
if (rememberMe) 
   cookie.setMaxAge(COOKIE_LIFETIME);
response.getCookieSettings().add(cookie);

This hands the cookie back to the client. On subsequent requests, the client
will (should?) send along any cookies with the same domain name as your server's
address, until they expire. Note that by default cookies expire when the browser
closes; to change this you need to call setMaxAge() as above.

As I understand it, class Cookie is used only for cookies on the client, while
CookieSetting is used for _setting_ cookies by the server. This confused me at
first too.

Hope this helps...
--Mike

Reply via email to