[Zope] Cookie

Tino Wildenhain tino@wildenhain.de
Wed, 08 Aug 2001 13:48:47 +0200


Hi Artur,

--On Mittwoch, 8. August 2001 13:06 +0200 Artur Mozdzynski <artur@abfab.nl> wrote:

> How to store a cookie in Zope?
> With RESPONSE.setCookie(name, value) I manage only to set a
> per-session cookie, which is not stored on a client computer.
>
> Zope reference gives such a header for this method:
> setCookie(name, value, **kw),
> but the **kw argument is not described.  What it is?
>

setCookie is a convenience function to construct the response
header. As this rfc header can have some additional attributes,
they can be given to the setCookie() method too.

Useful options are:
- expires  this should be set to a date/time in the Future, where
           the cookie is to be expired (hence the name ;)
           The format is Wdy, DD-Mon-YYYY HH:MM:SS GMT,
           so you might want to use DateTime().strftime() here.
- path     At least if you set "expires" you should send a path
           (minimum /) from which the cookie should work. Otherwise
           it gets not stored for old Netscape versions and a few
           proxies (Novell Bordermanager[tm] is known to behave like this)
- domain   The domain for which the cookie has to be send for each
           request. This defaults to the exact hostname of the server.

- secure   you can specify this with secure='' to get the browser sending
           it only over ssl.

HTH
Tino Wildenhain