RE: [Zope] Cookies Expiration
Oops, forgot to send this one to the list... -Original Message- From: Eric Walstad [mailto:[EMAIL PROTECTED]] Sent: Friday, November 03, 2000 3:40 PM To: Steve Drees Subject: RE: [Zope] Cookies Expiration Newbie_Alert Hi Steve, Your solution is very cool! I'm going to use it in the following form... (maybe a bit more flexible?, change the default days to suit your needs) ID: expireInNDays Parameter List: self, days=1.0 _BODY__ t = self.ZopeTime() + days # user defined duration t = t.toZone('GMT') return t.strftime("%A, %d-%b-%Y %H:%M:%S GMT") ___ On the page you want to set the cookie put: dtml-call "RESPONSE.setCookie('cookiename','cookievalue', path='/', expires=expireInNDays(this(), 7.0))" or, to use the default of 1 day: dtml-call "RESPONSE.setCookie('cookiename','cookievalue', path='/', expires=expireInNDays())" Thanks -Eric. /Newbie_Alert // -Original Message- // From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Steve // Drees // Sent: Friday, November 03, 2000 2:02 PM // To: Kit O'Connell; [EMAIL PROTECTED] // Subject: RE: [Zope] Cookies Expiration // // // However, I'd like to have this cookie set to expire one week // from the date // of the current visit. i.e., if its 12:30 on 11/3 when a surfer // visits my // site, I want Zope to set their lastVisited cookie to expire on 12:30 on // 11/10. // // Have a pythonmethod // // ID expireIn1Week // Parameter List self // _BODY__ // t = self.ZopeTime() + 7.0 # 1 week in the future // t = t.toZone('GMT') // // return t.strftime("%A, %d-%b-%Y %H:%M:%S GMT") // ___ // // // On the page you want to set the cookie put // dtml-call "RESPONSE.setCookie('cookiename','cookievalue', path='/', // expires=expireIn1Week())" // // // // // ___ // Zope maillist - [EMAIL PROTECTED] // 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 ) // ___ Zope maillist - [EMAIL PROTECTED] 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 )
[Zope] Cookies Expiration
I'm trying to set up something like is used in the Zope Elvis tutorial, where it sets a cookie to show when you last visited the site, so that I can flag certain articles as 'new'. However, I'd like to have this cookie set to expire one week from the date of the current visit. i.e., if its 12:30 on 11/3 when a surfer visits my site, I want Zope to set their lastVisited cookie to expire on 12:30 on 11/10. Any ideas? Thanks, Kit ___ Zope maillist - [EMAIL PROTECTED] 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 )
Re: [Zope] cookies don't obey me
Roland Reumerman writes: 1) When I set a cookie with the path set to the root dtml-call "RESPONSE.setCookie('account',AUTHENTICATED_USER,path='/')" Be careful with "cookies"! The value of a cookie it quite severely restricted (must not contain many characters; you read the cookie specification?). In your case, the value is not a string at all but a Zope object. "RESPONSE.setCookie" will probably convert the object to a string for you. This will give you "AUTHENTICATED_USER.getUsername()". However, I would feel better, if this would be in your "setCookie" call. Note, that probably Zope user names may contain characters not allowed in Cookie values. I'm still not able to click through to another hyperlink once I'm logged in, i.e., I've used www.ddi.nl/support to go the password protected Zope site, logged in as a customer, and from there I can choose other parts of the site (below .../support/). However, www.ddi.nl is an alias of www.datadistilleries.com (the actual name): as a result it asks me for the password again. I thought setting the path to '/' would convince Zope I'm authorized, but apparently it's not the case. The path is a "local" path on your server. Setting "path='/'" tells the browser to add the cookie to any request going to your server. "path='/'" would tell the browser to send it only for requests with paths beginning with "/". You cannot control with "path" to what server the cookie is sent. There is the "domain" specification that gives you some control over the servers that get the cookie. I doubt, however, that this mechanism will allow you to send cookies defined by "www.ddi.nl" also to "www.datadistilleries.com". 2) This might be related to 1. I've created a logout link on the /support/index_html page, which looks as follows: dtml-call "RESPONSE.expireCookie('account',path='/')" dtml-call "RESPONSE.redirect('http://www.datadistilleries.com/support.html?section=m6envelope=6')" However, once I've been redirected I can still access the password protected /support/ site without Zope asking me for a login name. There must be some magic, you did not yet tell us about. Usually, setting a cookie has nothing to do with password protection or authentication. There must be something like a "login manager" that ties Zope's security subsystem, login/logout and cookies together. Usually, this "login manager" would do the cookie handling transparently. That you are concerned with the cookie seems to indicate that you implement your own "login manager"? The built in Zope authentication does not use cookies at all but "basic authentication" as defined by HTTP. Dieter ___ Zope maillist - [EMAIL PROTECTED] 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 )
[Zope] cookies don't obey me
I've been experiencing two problems with cookies from Zope: 1) When I set a cookie with the path set to the root dtml-call "RESPONSE.setCookie('account',AUTHENTICATED_USER,path='/')" I'm still not able to click through to another hyperlink once I'm logged in, i.e., I've used www.ddi.nl/support to go the password protected Zope site, logged in as a customer, and from there I can choose other parts of the site (below .../support/). However, www.ddi.nl is an alias of www.datadistilleries.com (the actual name): as a result it asks me for the password again. I thought setting the path to '/' would convince Zope I'm authorized, but apparently it's not the case. 2) This might be related to 1. I've created a logout link on the .../support/index_html page, which looks as follows: dtml-call "RESPONSE.expireCookie('account',path='/')" dtml-call "RESPONSE.redirect('http://www.datadistilleries.com/support.html?section=m6envelope=6')" However, once I've been redirected I can still access the password protected .../support/ site without Zope asking me for a login name. Now, I'm not 'cookie guru', so please don't tell me how stupid it is of me that I didn't think of this or that to make it work. I did do my background research homework though! Thanks for reading this far ;-). RCR _ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. Share information about yourself, create your own public profile at http://profiles.msn.com. ___ Zope maillist - [EMAIL PROTECTED] 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 )
Re: [Zope] cookies
http://www.zope.org/Members/BwanaZulia/cookies/index_html That should help. J From: "Vincent Maton" [EMAIL PROTECTED] Date: Tue, 4 Jul 2000 15:45:55 +0200 To: "Zope" [EMAIL PROTECTED] Subject: [Zope] cookies Hello !!! can you tell me how can I use the "cookies" Thank you very much ___ Zope maillist - [EMAIL PROTECTED] 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 ) ___ Zope maillist - [EMAIL PROTECTED] 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 )
Re: [Zope] cookies
Hi Vincent ! Vincent Maton schrieb: Hello !!! can you tell me how can I use the "cookies" Just go to the following page: http://zdp.zope.org/portals/developers/sessionmanagement/cookies If you find another resource that we have overlooked, please add it yourself on this page. People can then see your contribution on the following page, which lists all things that change or have been added to the ZDP site: http://zdp.zope.org/SearchLastChanged/ Best regards, Maik Röder ___ Zope maillist - [EMAIL PROTECTED] 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 )
[Zope] cookies
Hello !!! can you tell me how can I use the "cookies" Thank you very much ___ Zope maillist - [EMAIL PROTECTED] 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 )
Re: [Zope] cookies
can you tell me how can I use the "cookies" try: dtml-call "RESPONSE.setCookie('blurk', 'nonsens')"/p dtml-if "REQUEST.cookies['blurk']" dtml-var "REQUEST.cookies['blurk']" dtml-else no blurk today /dtml-if Also see the relevant portion of the DTML reference guide http://www.zope.org/Documentation/Guides/DTML-HTML/DTML.4.5.html#pgfId-10470 78 and the dtml-snippet http://zdp.zope.org/projects/zsnippet/snippets/ClientServerInteraction/SetCo okie Rik ___ Zope maillist - [EMAIL PROTECTED] 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 )
RE: [Zope] Cookies
-Original Message- From: Mabe, Brad [mailto:[EMAIL PROTECTED]] Sent: 25 May 2000 16:29 To: '[EMAIL PROTECTED]' Subject: [Zope] Cookies I am trying to create a cookie based on the value returned from a sql method. The following code fails with an invalid syntax error. dtml-in SQL_get_cntry dtml-call "RESPONSE.setCookie('country_cookie', dtml-var cntry_cd)" dtml-in Hi, Inside quotation marks, you're writing python, so dtml-var cntry_cd makes the parser barf. cntry_cd is pushed onto the namespace by the dtml-in, so you can simply use: dtml-in SQL_get_cntry dtml-call "RESPONSE.setCookie('country_cookie', cntry_cd)" /dtml-in Note also the slash in the closing /dtml-in. hth, -- Marcus ___ Zope maillist - [EMAIL PROTECTED] 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 )