[ZDP] cookies again

Martijn Pieters mj@antraciet.nl
Wed, 26 May 1999 12:17:34 +0200


At 23:13 25/05/99 , Tom Deprez wrote:
>Sorry Martijn,
>
>I've still a question on cookies.
>
>Why do you create two cookies? ie. ZDP_Session and ZDP_Last_Visit
>
>What is the difference between them? Why not only using ZDP_Last_Visit.

One is for the current session (a session ends when the user closes 
his/her/its browser). The other is the latest access time at _any moment_.

If I only used ZDP_Last_Visit, it would only work on the first request of 
the first page. At that moment, the ZDP_Last_Visit cookie is reset to the 
current time. The tree will be displayed using the cookie before it was 
reset, and will neatly mark changed documents.

However, when you click any link, including one of the tree +/- icons to 
expand or collapse a branch, your browser makes a new request, and send the 
now-updated ZDP_Last_Visit cookie along, with the date of the previous 
request! Now the tree will only mark documents that have changed since the 
previous page. Usually that will be none.

Therefore, we have to use ZDP_Session. If that cookie is not present, we 
know that the visitor hasn't been here since it opened the browser. We can 
safely assume that ZDP_Last_Visit is some time in the past, we copy it to 
ZDP_Session, and use the last from now on.

Now, when clicking on a link, we find the ZDP_Session cookie, containing 
the not-updated date of the last visit. ZDP_Last_Visit will contain the 
date and time of the previous request. The tree marks all documents using 
ZDP_Session. When the user closes the browser, all non-persistent cookies 
(those with no explicit expiration date and time) are deleted, including 
ZDP_Session. ZDP_Last_Visit does have an expiration date and time, so will 
be maintained. Next visit, we start again.

To summarize: We cannot detect when a session ends, at which point we 
really want to set ZDP_Last_Visit. So we have to set ZDP_Last_Visit at 
every opportunity, and detect when a session _begins_. At the beginning of 
a session we store the real last visit to ZDP in a temporary cookie. At the 
end of a session ZDP_Last_Visit will contain the date of the very last 
visit, and the session cookie ZDP_Session will be deleted.

PS. I made a minor change to zb_menu, fixing a potential cookie bug. 
According to the specification, expiration dates should be expressed in the 
GMT timezone, so I had to force the current date and time to that timezone 
before turning it into a future expiration date.
'
--
Martijn Pieters, Web Developer
| Antraciet http://www.antraciet.nl
| Tel: +31-35-6254545 Fax: +31-35-6254555
| mailto:mj@antraciet.nl http://www.antraciet.nl/~mj
| PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149
------------------------------------------