Here's the code I use from python: RESPONSE.setCookie('cookiename', 'cookie value', path='/', expires='Sunday 20-05-001 12:00:00 GMT') Or, with no expiration: RESPONSE.setCookie('cookiename', 'cookie value', path='/') To do this from DTML would look like: <dtml-call expr="RESPONSE.setCookie('cookiename', 'cookie value', path='/', expires='Sunday 20-05-001 12:00:00 GMT')"> Or: <dtml-call expr="RESPONSE.setCookie('cookiename', 'cookie value', path='/')"> This works fine in python 1.5.2, zope 2.3.1. -Randy FYI, the 4th parameter is self, an implicit parameter to a python method.
-----Original Message----- From: Tommy Johnson [mailto:tommy@7x.com] Sent: Friday, May 18, 2001 4:12 PM To: zope@zope.org Subject: [Zope] Setting a Cookie
Hey all,
I'm trying to set a cookie. Simple right? hehe - if so, then I wouldn't be here. ;-)
Ok, I have the syntax in front of me. I have this bit of code to set the cookie:
<dtml-call "RESPONSE.setCookie('CookieMonster', '458468')">
All is well when I save the dtml document and when I run the page. The problem - the cookie isn't set!
Now I remember this problem when I worked with ASP. It turns out that you had to set an expire date also (although they said that if you didn't, the cookie expires when you close the browser and nothing gets written to the client machine.) That would be good - IF ONLY I COULD ACCESS THE INFORMATION I SET.
Sorry 'bout that. But it's fustrating to see this problem come up again with another language.
So I set an expire date. But, get this, now it fails when the page is loaded. The error message says that the method expected three parameters, but received four. Do you see four parameters here?
<dtml-call "RESPONSE.setCookie('CookieMonster', '458468', 'Sunday 20-05- 2001 12:00:00 GMT')">
I initially had a comma between Wdy, Date - because that is the DOCUMENTED syntax, but this seems incorrect also.
Here's the error message:
Error Type: TypeError Error Value: too many arguments; expected 3, got 4
Any suggestions? Proven code would be appreciated.
Thanks in advance, Tommy
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )