Re: [Webware-discuss] [Slightly off-topic] Cookies driving me mad (Was: MiddleKit: Something wrong with list of ?)

Mon, 02 Jul 2001 19:37:00 -0700

At 03:26 PM 6/28/2001 +0200, F. GEIGER wrote:
>which yields 'C1627001'. But that's a yesterday's value! As a result cookie
>and some database contents do not match.
>
>I mean, I set 'C1628000' calling self.response(setCookie(...) and get
>'C1627001' from yesterday, when I call self.request().cookies(...)!
>
>Can anyone enlighten me? What do I do wrong?
>
>Too me it seems, that the cookie is not transferred to the browser (MSIE
>5.5, cookies are activated), so I tried a 'self.writeln(" ")' as I thought
>this would force a transfer to the browser. But that doesn't work either.

You have the right idea. The cookie is not transferred to the browser until 
the response is actually delivered. request.cookie() is reading the cookies 
that came in while the response is just a cache of cookies that will go 
out. The 2 are disconnected.

I usually deal with this by putting the value of interest in an attribute. 
So in awake(), I might set it:

         self._value = self.request().cookie('foo')

Then later, if I change it, I do:

         self._value = expression()
         self.response().setCookie('foo', self._value)

Then later in my code I just use self._value and consider the request and 
response cookies to be "I/O channels" if you will.


-Chuck


_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to