Mehr Kekse zu Weihnachten

Die Weihnachtszeit rückt unhaltbar näher. Bei Aldi gibt es seit langem schon wieder Dominosteine, Lebkuchen usw.

 Auf der ständigen suche nach einer Verknüpfung zwischen der Windowsanmeldung und dem WISE Login hat Gorden einen Lösungsweg mit mod sspi für den Apache eingeschlagen.

Dafür benötigt er noch etwas Hintergrund zum setzen und auslesen von Cookies in DTML

Hier stehen einige meiner ungefilterten Rechercheergebnisse zum Thema. die aufzählung wird ständig erweitert…..

 Hier die Info aus den ZOPE Labs:

Using Cookies with Zope

Submitted by: grifter
Last Edited: 2004-10-14Category: DTML

Average rating is: 3.33 out of 5 (3 ratings)

Description:
What is a Cookie? Cookies are strings of text that webservers
(like Zope) can store on the client browser to record small
bits of data like user names, current positions, last visits,
etc. They are written to client file system either in one
long cookies.txt file for Netscape or in a directory for I.E.

(Note: This is not my material. My footnote says it was
originally created by BwanaZulia)


Source (Text):

Set cookie: <dtml-call "RESPONSE.setCookie('favorite_language', 'Python', expires='Wed, 19 Feb 2020 14:28:00 GMT')">  Read cookie: <dtml-if "REQUEST.has_key('favorite_language')">   <dtml-var favorite_language> </dtml-if>

Explanation:
Example One

Say you want to set a cookie that stores the name of your favorite
programming language (this is not supposed to be useful, just an
example). Copy and paste this into a DTML Document, view it,
shutdown your browser, find your cookies and see if it worked.

<dtml-call “RESPONSE.setCookie(‘favorite_language’, ‘Python’, expires=’Wed, 19 Feb 2020 14:28:00 GMT’)”>

Note:The expiration date can be any date you want but if you do not set one the cookie will expire when the browser is shutdown.

Now, if you wanted to get it back you need to check for it and call
it.

<dtml-if “REQUEST.has_key(‘favorite_language’)”>
<dtml-var favorite_language>
</dtml-if>

Example Two

Now you want to store some user name and email address (like I do
in ZUBB). The user name and email address are set in a form the
posts to this example so we can skip the dtml-call step.

<dtml-call “RESPONSE.setCookie(‘user_name’, user_name, expires=’Wed, 19 Feb 2020 14:28:00 GMT’)”>

<dtml-call “RESPONSE.setCookie(’email_address’, email_address, expires=’Wed, 19 Feb 2020 14:28:00 GMT’)”>

Note: notice that the second email_address, the actually zope
variable, is not in single quotes.

Now in ZUBB I want to check for the cookie (user name/email address)
and insert it into the post/reply form if it is there.

Tips for Working with and Testing Cookies

Find your cookie file and get ready to open it (you might have to
close your browser first).

Keep two different browsers open (IE, Netscape), leave one as the
test and the other to code in Zope.

Set the test browser to “warn before accepting cookies” (or
whatever it says).

Be ready to shutdown and reboot your brower every five seconds.

You can create a DTML Method called “cookies” or some such thing
and call it from your standard_html_header.

1. Formular zum Cookie setzen

<FORM NAME=”formular” METHOD=”POST” ACTION=”report”><P>
Name: <INPUT TYPE=”TEXT” NAME=”qkey” SIZE=30 MAXLENGTH=30><BR>
Value: <INPUT TYPE=”TEXT” NAME=”qvalue” SIZE=30 MAXLENGTH=30><BR>
<INPUT TYPE=”submit” VALUE=”Submit”>
</Form> 

2. Formular auswerten  Cookie setzen

<p>
Das Cokie ist plaziert !!!
<dtml-call “RESPONSE.setCookie(_[‘qkey’],_[‘qvalue’],
expires=’Wed, 19 Feb 2020 14:26:00 GMT’)”>
</p>

3. Cookie lesen

<p>
das Cokie heisst:<BR>
<dtml-in expr=”REQUEST.cookies.keys()”>
<dtml-var sequence-item> –> <dtml-var expr=”REQUEST.cookies.get(_[‘sequence-item’])”><br>
</dtml-in>
</p> 

Beispiele sagen mehr als tausend worte…..

Mickey

This entry was posted in Allgemein. Bookmark the permalink.

Leave a Reply