Graham Dumpleton
grahamd at dscpl.com.au
Fri Nov 17 04:21:11 EST 2006
On 17/11/2006, at 8:09 PM, Istvan De wrote: > Hi! > > In my code, if I detect that a cookie is not set, I set it using > Cookie.add_cookie(). > > That is all well. However, if I read this cookie from the same request > at which it was added, it is not available. I guess this is because > the > "cookie add" function puts the cookie into the reponse of the page, > and > the "cookie get" function only looks at the request to see what > cookies > are set. > > What is the solution to my problem? Cookie.get_cookies() reads from req.headers_in. Cookie.add_cookie() writes to req.headers_out. Thus, you can't read back what you only just wrote. Suggest you log using apache.log_error() the values of the input and output headers to see what they are set to. Note that Cookie.add_cookie() must be called prior to the first time that any actual content is written back as the response. Graham
|