CGI, cookies & mod_perl

barbie on 2002-10-11T12:00:46

After the last week of being baffled as to why session entries keep dropping, I suddenly discover the code in CGI.pm to be at fault.

Running under mod_perl, the cookies are cached by CGI.pm. If those values change they are ignored in preference to the cached versions. I now call CGI::Cookie->fetch directly. A shame the CGI pod page doesn't mention it though. Might have saved me a weeks worth of tweeking.


that smells like a bug

merlyn on 2002-10-11T14:14:25

I know that CGI.pm has special mod_perl code to add a cleanup handler to reset back to initial state. If that's not working for you, please report the bug.

Re:that smells like a bug

barbie on 2002-10-11T18:13:07

I don't think it's a bug, more the way that CGI->cookie() works. I'm using the NMS version of cookielib, which uses it, although I've changed it to use the CGI::Cookie->fetch mechanism for our purposes.

If there are special mod_perl prerequisites then they aren't specified under the "HTTP COOKIES" section of the POD, which is where I would have expected them. I checked for mod_perl references in the POD, of which there are two, and neither mention anything about the handling of cookies :(

I've notice a few people have had similar problems, but virtually all the references in archives are around 5 years old. There's nothing that I could find in the docs on the perl.apache.org site either.

It works for now, and after we've got the load testing and deployment to 6 clients over the next two weeks, I'll investigate further. Might end up being added to an FAQ somewhere.

It's been a nice learning experience though :)