in reply to Problem setting cookie using CGI::Cookie

&url prints a header

You only get to print the header once per invocation. You have to stick the cookie in there before you print it. I'm not having much luck making sense out of your variable names or comparisons, so I can't say for sure that this is your problem, but checking the request method sure looks like it'll print the header too eary to set a cookie.

By the way, calling a sub with the &url syntax is not only ugly, it does things implicitly that you may not want. See perlsub for more. I much prefer url() and recommend that you consider it.