[Zope] Cookies and Python Scripts

Matthew Anderson Matthew.Anderson@ftech.net
Tue, 19 Mar 2002 10:39:13 -0000


Hi,

I am experiencing cookie 'weirdness' on Zope (V 2.5.1b1)...

I have two python scripts that are called from within a DTML Method.
The first, py_cookie_read(foo) attempts to read an existing cookie and =
returns 1 if a value is present or 0 if the value is not present.=20
The second, py_cookie_set(foo) attempts to overwrite the cookie with a =
new value after an action has been taken (voting in a poll).

The code I use to read from the cookie is as follows:
     poll_cookie =3D context.REQUEST.cookie['poll']

And the code I use to set the cookie is as follows:
     context.REQUEST.RESPONSE.setCookie('poll', new_poll_cookie, =
expires=3Dexpiry)=20
     - where new_poll_cookie and expiry are variables set in the same =
script.

The 'weirdness' that am I experiencing is that the cookie is rarely set =
and certainly never read properly. The few times that I have observed it =
in the REQUEST list - it has appeared under 'form' variables and 'other' =
variables but never 'cookie' variables.

I think it may have something to do with the 'context' under which I am =
trying to set and read the cookies even though both scripts are called =
from within the same DTML Method - perhaps the cookie is only associated =
with individual python scripts?

Any suggestions would be greatly appreciated...

Cheers,

Matt

BTW - cookies are enabled in my browser :-)
--
Matthew Anderson - Web Designer - Frontier Internet Services Limited
Tel: 029 20 820 019   Fax: 029 20 820 037   http://www.frontier.net.uk
Statements made are at all times subject to Frontier's Terms and =
Conditions of Business, which are available upon request.