[Zope] Re: Cookie Dictionary

Josef Meile jmeile@hotmail.com
Fri, 14 Mar 2003 22:15:15 +0100


Hi Rick,

> Can you store a dictionary in a cookie? I've been trying and it keeps
> barfing on me. If I set the dictionary in the REQUEST, it works just
> fine, but if I set it as a cookie, and then try to reference it with
> <dtml-var "cookie['key']"> if bombs with "sequence index must be an
> integer". Dost it think it's a list?

Do you need a dictionary, or  can a list be useful too? On this case,
you could send a coma delimited string and then use the split method
to convert it to a list.

You could also use more delimiters for example:
a1,b1;a2,b2;...;an,bn

and then split the string by the semi-colons. Then go through each element
and split by the commas; However, this solution is not efficient nor
elegant,
but it could be an alternative.

Again, as Geir said, you are limmited to 255 characters (not sure about this
number) when working with cookies. You can also get rid of it by using this
piece of code:
http://www.zope.org/Members/gaaros/localcookies

Regards,
Josef