I see many solutions for storing multiple values in one cookie in .Net and php but I have not found any good solution for Java. I dont wanna encode/decode the pair-values myself which can be risky.
A:
The usual approach is to save a unique ID in the cookie (just a long number) and use a synchronized map in your code which gives you some data structure per ID (often another map).
Aaron Digulla
2009-10-06 07:49:38
This sounds to complicated and needs some strategy when restaring the java. I just want to save a couple of name/vaule pairs.
Johannes
2009-10-06 08:29:34
This is usually handled by your app server. For anything that supports servlets, just use `getSession()` to get access to such a map.
Aaron Digulla
2009-10-06 08:55:47
Thx man! I thought I had to use the Cookies class, but this seems to be just what I need :) I will try it out now!
Johannes
2009-10-06 11:45:12
As you asked for help in encode/decode, this library helps to stay in tune with the specifications. See org.apache.commons.httpclient.cookie.CookieSpecBase, Cookie.toExternalForm(), etc . This is not server/client specific.
PeterMmm
2009-10-06 10:20:44