[Zope] override cookie espacing?

Oliver Bleutgen myzope@gmx.net
Mon, 30 Sep 2002 16:50:12 +0200


John Doe wrote:
> Hi,
> 
> Is it possible to override the way Zope escapes it's
> cookies?  When a cookie is set by Zope (eg. when you
> consult the help or by setting it with
> REQUEST.RESPONSE.setCookie), the cookie-value is
> enclosed by escaped quotes (eg \"mycookievalue\"). 
> 
> I would like to use quote-less cookievalues because it
> confuses some log-analyzing programs. 
> 
> Anyone encountered this problem (and preferrably it's
> solution)?


I'm quite sure you can't change that behaviour of setCookie(), because 
it's hard-coded in ZPublisher.HTTPResponse._cookie_list.
But you should be able to use RESPONSE.appendHeader:

def appendHeader(self, name, value, delimiter=","):
         '''\
         Append a value to a cookie

         Sets an HTTP return header "name" with value "value",
         appending it following a comma if there was a previous value
         set for the header. '''

and append the right header to you response, something like
RESPONSE.appendHeader('Set-Cookie:', 'cookie_name = cookie_value, <other 
headers>')

For right syntax of the "Set_cookie"-header, there's a RFC, or look up 
in google.

HTH,
oliver