[Zope] setting cookies in a python script? (OmniWeb issue)
Marc Dumouchel
marc.dumouchel@powersurfr.com
Fri, 28 Sep 2001 14:59:42 -0600
On our Zope site (www.su.ualberta.ca), we have a splash page
that lets users choose which version of the site they want to
see. That page has links to two methods, each of which set two
cookies:
splash --> gets set to 'yes', this prevents the user from
encountering the splash page on subsequent visits.
bandwidth --> gets set to either 'high' or 'low', depending on
which method they click through to.
The code for one of the methods, "setBandwidthHigh", (the other
is almost identical):
<dtml-call "RESPONSE.setCookie('bandwidth', 'high',
domain='su.ualberta.ca', expires='Wed, 19 Feb 2020 14:28:00
GMT')">
<dtml-call "RESPONSE.setCookie('splash', 'yes',
domain='su.ualberta.ca', expires='Wed, 19 Feb 2020 14:28:00
GMT')">
<dtml-call "RESPONSE.redirect('index_html')">
The problem I have is with a browsers such as OmniWeb 4.0.5 (Mac
OS X). OmniWeb adds the path of the method to the cookie, so
the cookie gets listed in this form:
domain: su.ualberta.ca
path: /setBandwidthHigh
name: bandwidth
value: high
Other browsers simply list the path as /, and work just fine.
Omniweb doesn't work, because when index_html checks for the
cookie, the cookie as listed doesn't show up because the path is
too specific. Doing a <dtml-var REQUEST> shows no cookie
entries under OmniWeb (unless I include the path in the URL-
e.g. "www.domain/setBandwidthHigh/samplepage/". Instead, the
splash page just comes back up.
I'm still pretty new to Python, but I was thinking that if I put
a form button on the page to select the site version, I could
have a Python script execute when it clicked that set the cookie
properly in OmniWeb (i.e., with a path of '/'). Can I set
cookies from within a Python script? Any other suggestions to
solve my problem?