[Zope] cookies

Andreas Hölzl hoelzla@uni-freiburg.de
Sat, 22 Jun 2001 18:53:22 +0200


maybe this could be a hint to the solution of your problem:

if you have problems with the "visibility" of your cookies use:
setCookie(..., path='/', ...)

in general cookies are set via the "set-cookie"-tag in the
http-header.
So you allways have to be sure, that a page (maybe dummy-page with
redirect) with a "set-cookie"-header is delivered to the
client-browser bevore referencing to the cookie in the context of
another page.

maybe the API-method "expireCookie" can also be used fruitfully.

Andreas

-------------------
> hello ng,
> 
> I've a problem with setting and using cookies.
> 
> My Website is completely folder-structured. My Menue lists the
foldernames
> and each folder inherits the index_html from the root folder. The
> foldernames are properties (english or german)
> 
> Now I want to switch between two languages. The idea is that the
user clicks
> on "german" and a cookie is set with the name 'lang' and its value
'german'.
> Then the page is reloaded with the german folder-names and different
> content. If the user clicks on english again, the cookie should be
> overwritten with the value 'english'. The cookie is only set or
changed by
> clicking on the switch-button.
> The webpage should work like that:
> 
> <dtml-if expr="lang=='english'">
>  ...english content and english menue
> <dtml-elif expr="lang=='deutsch'">
>  ...german content and german menue
> </dtml-if>
> 
> 
> I've tried to realise the switching in this way.
> 
> the code in the index_html: ("switch-button")
> 
>               <dtml-if expr="lang=='english'">
>                <a href="&dtml-absolute_url;/sprache_de">Deutsch
>               <dtml-elif expr="lang=='deutsch'">
>                <a href="&dtml-absolute_url;/sprache_en">English
>               </dtml-if>
> 
> Two Methods in the rootfolder set the cookie. ("switch-methods")
> 
>   Sprache_de: switching from english to german
> 
>     <dtml-call "RESPONSE.setCookie('lang', 'deutsch')" >
>     <dtml-call expr="RESPONSE.redirect(URL1)">
> 
>   Sprache_en: switching from german to english
> 
>     <dtml-call "RESPONSE.setCookie('lang', 'english')" >
>     <dtml-call expr="RESPONSE.redirect(URL1)">
> 
> I had always a look at the REQUEST and I saw that this doesn't work
very
> well.
> Sometimes the cookie isn't set. Or I can see the changes, if I click
on
> another folder. Another problem is that some folders are english and
some
> are german at the same time. But I wanted to use the cookie as a
global
> variable in order to have either a english or a german version
provided to
> the user. Does every folder creates its own cookie. I want to be
able to
> switch the language also in subfolders.
> 
> I hope you got my problem. It isn't easy to explain as short es
possible.
> 
> Thanks,
> 
> Tapio
> 
> 
> _______________________________________________
> 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 )
>