It looks like this may be an issue with the code. I moved the bit that prints the header to earlier in the code and it now works, but the cookies printed later are now showing as text. I guess mod_perl isn't keen on having print statements for these things littered around the code, so I will have to try and unpick everything.