[Zope] Problems with setCookie
Jonathan Hobbs
toolkit at magma.ca
Fri Aug 27 07:52:54 EDT 2004
----- Original Message -----
From: <jens.walte at kk.net>
> As i know, there's always only one cookie for one url.
> And 'test1' is the key with it's value 'value1'.
>
> like:
> ----------------------- cookie-souce
> test_data1
> "t1"
> xf130lg/
> 1024
> 2778255872
> 30795568
> 2735860320
> 29657955
> *
> test_data2
> "t2"
> xf130lg/
> 1024
> 2778255872
> 30795568
> 2735860320
> 29657955
> *
> test_data3
> "t3"
> xf130lg/
> 1024
> 2778255872
> 30795568
> 2735860320
> 29657955
> *
> -----------------------
>
> the 'problem'-server only gets
> ----------------------- cookie-souce
> test_data3
> "t3"
> xf130lg/
> 1024
> 2778255872
> 30795568
> 2735860320
> 29657955
> *
> -----------------------
> with the same script...
We use routines which set multiple cookies without any problems...
Each call to RESPONSE.setCookie('cookiename', 'cookievalue') will create a
new cookie if 'cookiename' is different (ie. you can have multiple cookies
set by the same routine). Using the same 'cookiename' will overwrite the
previous contents of the cookie.
One thing to check is that RESPONSE.setCookie sets a cookie in the user's
browser, but that cookie is NOT seen in REQUEST until the user next accesses
your zope system. (ie. the zope mechanism does not set the cookie until the
current routine completes successfully. Therefore if you set the cookie and
then check for the cookie value right away (ie. in the same routine that
sets the cookie) you won't see the cookie value (one way to get around this
is to set the cookie and then set a variable in REQUEST with the same
name/value as the cookie you just set).
A quick way to check your cookies is to have two routines: the first sets
your 3 cookies and does nothing else; the second just displays the contents
of REQUEST. Manually invoke the first routine and when it finishes,
manually invoke the second routine. This should eliminate any other
possible causes of problems and let you see if the cookies are being set
properly.
HTH
Jonathan
More information about the Zope
mailing list